Extremal graphs with respect to the Zagreb coincides