“Subgraph of any graph G is a graph having subset of vertices and edges of G.”
in our original graph there are 4 vertices (p,q,r,s) and 5 edges (e1,e2,e3,e4,e5)
subgraph having 1 edge only:
case 1: take all 4 vertices but only 1 edge
so see in our original graph , if we have all vertices then number of edges between them = 5.
but we want subgraph with all vertices but only one edge so choose only one of 5 edges which can be done in 5C1 ways =5.
case (2.1): take 3 vertices(p,q,r) but only 1 edge
see in our original graph , if we have 3 vertices(p,q,r) then number of edges between them = 4 (e1,e2,e3,e4)
but we want subgraph with vertices p,q,r that have only one edge so choose only one of 4 edges which can be done in 4C1 ways =4.
case (2.2): take 3 vertices(p,q,s) but only 1 edge
see in our original graph , if we have 3 vertices(p,q,s) then number of edges between them =2 (e1,e5)
but we want subgraph with vertices p,q,s that have only one edge so choose only one of 2 edges which can be done in 2C1 ways =2.
case (2.3): take 3 vertices(p,s,r) but only 1 edge
see in our original graph , if we have 3 vertices(p,s,r) then number of edges between them is only one (e4)
so only 1 way.
case (2.4): take 3 vertices(s,q,r) but only 1 edge
see in our original graph , if we have 3 vertices(s,q,r) then number of edges between them =4 (e2,e3,e4,e5)
but we want subgraph with vertices s,q,r that have only one edge so choose only one of 4 edges which can be done in 4C1 ways =4.
Case:(3.1) : take 2 vertices (p,q) but only 1 edge
see in our original graph , if we have 2 vertices(p,q) then number of edges between them =1 (e1)
so only 1 way.
Case:(3.2) : take 2 vertices (p,s) but only 1 edge
see in our original graph , if we have 2 vertices(p,s) then number of edges between them =0.
so ignore all such combination of vertices where no edge there in original graph.
Case:(3.3) : take 2 vertices (p,r) but only 1 edge
see in our original graph , if we have 2 vertices(p,r) then number of edges between them =1 (e4)
so 1 way.
Case:(3.4) : take 2 vertices (s,r) but only 1 edge
see in our original graph , if we have 2 vertices(s,r) then number of edges between them =1 (e4)
so 1 way.
Case:(3.5) : take 2 vertices (q,r) but only 1 edge
see in our original graph , if we have 2 vertices(q,r) then number of edges between them =3 (e2,e3,e4)
so 3 ways.
Case:(3.6) : take 2 vertices (q,s) but only 1 edge
see in our original graph , if we have 2 vertices(q,s) then number of edges between them =3 (e5)
so 1 way.
Case:(4) : take only vertex r
see in our original graph , if we have only vertex r then number of edges in it =1(e4)
so only 1 way.
so doing total = 1+1+3+1+1+1+4+1+2+4+5 =24.
similarly we can do for subgraphs having 2 edges also.
i hope you get it ..