HelpOld:=proc(): print(`G(n), Friends(G,v), FriendsS(G,Sv) `): print(`Cc(G,v) , IsConnected(G,n), CG(n)`): end: Help:=proc(): print(`NuCGs(n) , NuCG(n), NuCGe(n,e), Image(G,pi)`): print(`NuUCG(n)`): end: with(combinat): #G(n): the set of ALL labelled graphs on n vertices G:=proc(n): powerset(convert(choose({$1..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: #NuCGs(n): the first n terms in the counting #sequence of labelled connected graphs #using direct counting (very stupid, don't #even try n>=6 NuCGs:=proc(n) local i: [seq(nops(CG(i)),i=1..n)]: end: #NuCG(n): NuCG:=proc(n) local f,t,i: f:=log(add(2^(binomial(i,2))*t^i/i!,i=0..n+1)): f:=taylor(f,t=0,n+1): [seq(i!*coeff(f,t,i),i=1..n)]: end: #NuCGe(n,e):The counting sequence for the #number of labelled connected graps with #i vertices and i-1+e edges for i=1..n NuCGe:=proc(n,e) local f,t,s: f:=log(add((1+s)^(binomial(i,2))*t^i/i!,i=0..n+1)): f:=taylor(f,t=0,n+1): [seq(i!*coeff(coeff(f,t,i),s,i-1+e),i=1..n)]: end: #Image(G,pi): The image of the labelled graph G #on {1, ..., n} by the perm. pi Image:=proc(G,pi) local i: map(x->map(y->pi[y],x),G): end: UCG:=proc(n) local A,S,P,pi,s: A:=CG(n): S:={}: P:=permute(n): while A<>{} do s:=A[1]: S:={s,op(S)}: A:=A minus {seq(Image(s,pi),pi in P)}: od: S: end: #NuUCGs(n): the first n terms in the counting #sequence of unlabelled connected graphs #using direct counting (very stupid, don't #even try n>=6 NuUCGs:=proc(n) local i: [seq(nops(UCG(i)),i=1..n)]: end: