I'm working on the inverse problems on topological induces. Actually I got a partial answer for my question. But I have to generalize this result. Please help me in this regard.
The path of length n has n-2 vertices of degree 2 and 2 of degree 1, hence a first Zagreb index of 4n-6. A cycle of n vertices has n vertices of degree 2, hence first Zagreb index of 4n. So every even number other than 4 occurs in one of these two families. The only way to express 4 as a sum of squares is as 4 or 1+1+1+1. There can't be a graph with one vertex of degree 2, but the graph on four vertices with two disjoint edges is a non-connected graph with four vertices of degree 1.