ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 04 Sep 2015 04:31:31 +0200How do I generate list of connected graphs with given number of vertices?https://ask.sagemath.org/question/29353/how-do-i-generate-list-of-connected-graphs-with-given-number-of-vertices/ I have used this short nauty program to generate graphs with given number of vertices, edges and degree information.
c =0
for G in graphs . nauty_geng (’9 12 -d4D4 ’) :
c = c +1
print " graph "+str( c ) +" ( graph6 string ’"+ G . graph6_string () +" ’):"
G . adjacency_matrix ()
G . show ()
print ""
print ""
It generates a list of all graph with given information. My query is that How do I filter them to get only connected ones?Tue, 25 Aug 2015 07:07:30 +0200https://ask.sagemath.org/question/29353/how-do-i-generate-list-of-connected-graphs-with-given-number-of-vertices/Answer by Nathann for <p>I have used this short nauty program to generate graphs with given number of vertices, edges and degree information.
c =0
for G in graphs . nauty_geng (’9 12 -d4D4 ’) :
c = c +1
print " graph "+str( c ) +" ( graph6 string ’"+ G . graph6_string () +" ’):"
G . adjacency_matrix ()
G . show ()
print ""
print ""</p>
<p>It generates a list of all graph with given information. My query is that How do I filter them to get only connected ones?</p>
https://ask.sagemath.org/question/29353/how-do-i-generate-list-of-connected-graphs-with-given-number-of-vertices/?answer=29354#post-id-29354If you read the documentation of nauty_geng, you will see that it has a '-c' flag to do exactly what you want. Tue, 25 Aug 2015 09:20:31 +0200https://ask.sagemath.org/question/29353/how-do-i-generate-list-of-connected-graphs-with-given-number-of-vertices/?answer=29354#post-id-29354Comment by siki_math for <p>If you read the documentation of nauty_geng, you will see that it has a '-c' flag to do exactly what you want. </p>
https://ask.sagemath.org/question/29353/how-do-i-generate-list-of-connected-graphs-with-given-number-of-vertices/?comment=29367#post-id-29367Could you please share that document with me? Or any link where I could find that.?Thu, 27 Aug 2015 06:56:03 +0200https://ask.sagemath.org/question/29353/how-do-i-generate-list-of-connected-graphs-with-given-number-of-vertices/?comment=29367#post-id-29367Comment by Nathann for <p>If you read the documentation of nauty_geng, you will see that it has a '-c' flag to do exactly what you want. </p>
https://ask.sagemath.org/question/29353/how-do-i-generate-list-of-connected-graphs-with-given-number-of-vertices/?comment=29369#post-id-29369By "document" are you refering to the documentation of nauty_geng? If so, know that you can get the doc of any Sage function with a question mark. In the present case, just type
graphs.nauty_geng?
In Sage.Thu, 27 Aug 2015 12:42:14 +0200https://ask.sagemath.org/question/29353/how-do-i-generate-list-of-connected-graphs-with-given-number-of-vertices/?comment=29369#post-id-29369Comment by siki_math for <p>If you read the documentation of nauty_geng, you will see that it has a '-c' flag to do exactly what you want. </p>
https://ask.sagemath.org/question/29353/how-do-i-generate-list-of-connected-graphs-with-given-number-of-vertices/?comment=29399#post-id-29399Yes, I meant the documentation of nauty-geng. I got you now. Thank you very much for your assistance Nathann..:)Fri, 04 Sep 2015 04:31:31 +0200https://ask.sagemath.org/question/29353/how-do-i-generate-list-of-connected-graphs-with-given-number-of-vertices/?comment=29399#post-id-29399