Help:=proc(): print(`G(n), Friends(G,v), FriendsS(G,Sv) `): print(`Cc(G,v) , IsConnected(G,n), CG(n)`): end: with(combinat): #G(n): the set of ALL labelled graphs on n vertices G:=proc(n): powerset(convert(choose(n,2),set)) : end: #Friends(G,v): all the friends of vertex v in G Friends:=proc(G,v) local F,e: F:={}: for e in G do if member(v,e) then F:=F union {{op(e)} minus {v} }[1]: fi: od: F union {v}: end: #The collective set of friends of Sv in G FriendsS:=proc(G,Sv) local v: {seq( op(Friends(G,v)), v in Sv)}: end: #IsConnected(G,n): Is the graph G (on {1, ..., n}) connected IsConnected:=proc(G,n) local i: evalb({seq(i,i=1..n)}=Cc(G,1)): end: #Cc(G,v): the transitive closure of friendships of v in G Cc:=proc(G,v) local S,NewS: S:={v}: NewS:=FriendsS(G,S): while NewS<>S do S:=NewS: NewS:=FriendsS(G,NewS): od: NewS: end: CG:=proc(n) local S,C,s: S:=G(n): C:={}: for s in S do if IsConnected(s,n) then C:={op(C),s}: fi: od: C: end: