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.Sun, 12 Feb 2017 07:44:46 +0100Generating non-bipartite graphs.https://ask.sagemath.org/question/36336/generating-non-bipartite-graphs/I use graphs.nauty_geng('n') to generate graphs on n vertices. By adding the flag -c (resp. -b), I will get filtered list of connected (resp. bipartite) graphs on n vertices. For example, see the following code:
c=0
for G in graphs.nauty_geng('6, -c'):
c=c+1
if not G.is_bipartite():
print "Graph" +str(c)+":"
G.show()
This will generate a list of connected non-bipartite graphs on 6 vertices. I want to do the same by avoiding the if loop I have used. For example by replacing above with graphs.nauty_geng('6,-b'), I can get the list of bipartite ones. Is there any direct command which works just like -b and -c work?
Thanks in advance.Wed, 18 Jan 2017 07:24:19 +0100https://ask.sagemath.org/question/36336/generating-non-bipartite-graphs/Comment by Siki for <p>I use graphs.nauty_geng('n') to generate graphs on n vertices. By adding the flag -c (resp. -b), I will get filtered list of connected (resp. bipartite) graphs on n vertices. For example, see the following code:</p>
<pre><code>c=0
for G in graphs.nauty_geng('6, -c'):
c=c+1
if not G.is_bipartite():
print "Graph" +str(c)+":"
G.show()
</code></pre>
<p>This will generate a list of connected non-bipartite graphs on 6 vertices. I want to do the same by avoiding the if loop I have used. For example by replacing above with graphs.nauty_geng('6,-b'), I can get the list of bipartite ones. Is there any direct command which works just like -b and -c work?</p>
<p>Thanks in advance.</p>
https://ask.sagemath.org/question/36336/generating-non-bipartite-graphs/?comment=36382#post-id-36382Here is a way to generate the disconnected graphs on n vertices using an if loop.
`c=0
for G in graphs.nauty_geng('n'):
c=c+1
if not G.is_connected():
G.show()`
As I am new here, I don't know how to add a code here to be looked like just a way it works in sage. I hope you understand anyway.Wed, 25 Jan 2017 09:55:08 +0100https://ask.sagemath.org/question/36336/generating-non-bipartite-graphs/?comment=36382#post-id-36382Comment by Siki for <p>I use graphs.nauty_geng('n') to generate graphs on n vertices. By adding the flag -c (resp. -b), I will get filtered list of connected (resp. bipartite) graphs on n vertices. For example, see the following code:</p>
<pre><code>c=0
for G in graphs.nauty_geng('6, -c'):
c=c+1
if not G.is_bipartite():
print "Graph" +str(c)+":"
G.show()
</code></pre>
<p>This will generate a list of connected non-bipartite graphs on 6 vertices. I want to do the same by avoiding the if loop I have used. For example by replacing above with graphs.nauty_geng('6,-b'), I can get the list of bipartite ones. Is there any direct command which works just like -b and -c work?</p>
<p>Thanks in advance.</p>
https://ask.sagemath.org/question/36336/generating-non-bipartite-graphs/?comment=36412#post-id-36412Here is the code to generate disconnected graphs on 5 vertices. Thanks for your assistance about adding a code.
c=0
for G in graphs.nauty_geng('5'):
c=c+1
if not G.is_connected():
print "Graph" +str(c)+":"
G.show()Mon, 30 Jan 2017 08:28:27 +0100https://ask.sagemath.org/question/36336/generating-non-bipartite-graphs/?comment=36412#post-id-36412Comment by Siki for <p>I use graphs.nauty_geng('n') to generate graphs on n vertices. By adding the flag -c (resp. -b), I will get filtered list of connected (resp. bipartite) graphs on n vertices. For example, see the following code:</p>
<pre><code>c=0
for G in graphs.nauty_geng('6, -c'):
c=c+1
if not G.is_bipartite():
print "Graph" +str(c)+":"
G.show()
</code></pre>
<p>This will generate a list of connected non-bipartite graphs on 6 vertices. I want to do the same by avoiding the if loop I have used. For example by replacing above with graphs.nauty_geng('6,-b'), I can get the list of bipartite ones. Is there any direct command which works just like -b and -c work?</p>
<p>Thanks in advance.</p>
https://ask.sagemath.org/question/36336/generating-non-bipartite-graphs/?comment=36581#post-id-36581Alright then.Sun, 12 Feb 2017 07:44:46 +0100https://ask.sagemath.org/question/36336/generating-non-bipartite-graphs/?comment=36581#post-id-36581