Ok to post Question 1: Generalize procedure NuConG(N) of M18.txt to write a procedure NuKcomponentsGraphs(N,K) that inputs a positive integer N and another positive integer K and outputs the first N terms of the sequence enumerating the number of labeled graphs on n vertices with Exactly K componets. Make sure that NuKComponentsGraphs(N,1) equals NuConG(N) for N ≤ 6 Hint: Of course, you first need to write a procedure AllKcomponentsGraphs(n,K) by tweaking procedure AllConGraphs(n) and change the line nops(CCs(s))=1 to nops(CCs(s))=k Are the following sequences in the OEIS? If yes, what are the A-numbers NuConGgen(5,2), NuConGgen(5,3) Answer 1: #AllKcomponentsGraphs(n, K): The set of all connected (labeled) graphs on {1,..,n} with K components AllKcomponentsGraphs:=proc(n, K) local S,s,C: S:=AllGraphs(n): C:={}: for s in S do if nops(CCs(s))=K then C:=C union {s}: fi: od: C: end: #NuKComponentsGraphs(N, k): The first N terms of the sequence "number of connected with K components (labeled) graphs with n vertices", by BRUTE force #Try: #NuConG(5); NuKComponentsGraphs:=proc(N, k) local n1: [seq( nops(AllKcomponentsGraphs(n1, k)),n1=1..N)]: end: NuConGgen(5,2) A323875 Number of labeled graphs on n nodes with two connected components. NuConGgen(5,3) A323876 Number of labeled graphs on n nodes with three connected components. Question 2 Using procedures RandGr(n,K) and CCs(G), in M18.txt write a procedure AveNuCC(n,K,M) that generates M random graphs on n vertices with K edges, and for each of them finds the number of components and take the average over these M random graphs. Run it several times with n=30 and M=1000 to check that you get close answers. If not what M would give such agreement? Answer 2 AveNuCC:=proc(n, K, M) local ans, i, G: ans :=0: for i from 1 to M do: #print(i): G:=RandGr(n, K): #print(G): ans:=nops(CCs(G))+ans: od: evalf(ans/M): end proc: We do very close answers. Question 3 EstimateCutOff(n,M) that inputs a positive integer n and outputs an estimate for the "threshold" for K, when most graphs with K edges start to be connected (say when the average number of connected componets is less than 1.05) Answer 3 EstimateCutOff:=proc(n, M) local ans, i: ans:=AveNuCC(n, 1, M): i:=1: while(ans>1.05) do: ans:=AveNuCC(n, i, M): i:=i+1: od: i: end proc: