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, 27 Nov 2020 14:42:12 +0100How to put the drawing of graphs in a matrix or listhttps://ask.sagemath.org/question/54381/how-to-put-the-drawing-of-graphs-in-a-matrix-or-list/I have got some graphs on 5 vertices.
count = 0
for g in graphs.nauty_geng("5 1:5"):
count = count+1
print(count)
we got 19 graphs. I want to show them but get long output using following codes, and it is very bad for viewing.
for g in graphs.nauty_geng("5 1:5"):
g.show()
I thought of using matrix or list storage these drawings of graph , but it failed.
glist= [g for g in graphs.nauty_geng("5 1:5")]
map(show,glist)
we got noting from outputs:
<map object at 0x6fdf37c3cf8>
This is what Maple did well.
with(GraphTheory):
graphsof5c := [NonIsomorphicGraphs(5, 1..5,output = graphs, outputform = graph)]:
DrawGraph~(graphsof5c,size=[300,300],stylesheet=[vertexborder=false,vertexpadding=20,edgecolor = "Blue",
vertexcolor="Gold"])
My points are less than 60 points, I can’t upload
corresponding pictures, sorry.Wed, 25 Nov 2020 10:27:09 +0100https://ask.sagemath.org/question/54381/how-to-put-the-drawing-of-graphs-in-a-matrix-or-list/Answer by fidbc for <p>I have got some graphs on 5 vertices. </p>
<pre><code>count = 0
for g in graphs.nauty_geng("5 1:5"):
count = count+1
print(count)
</code></pre>
<p>we got 19 graphs. I want to show them but get long output using following codes, and it is very bad for viewing.</p>
<pre><code> for g in graphs.nauty_geng("5 1:5"):
g.show()
</code></pre>
<p>I thought of using matrix or list storage these drawings of graph , but it failed. </p>
<pre><code>glist= [g for g in graphs.nauty_geng("5 1:5")]
map(show,glist)
</code></pre>
<p>we got noting from outputs:</p>
<pre><code><map object at 0x6fdf37c3cf8>
</code></pre>
<p>This is what Maple did well.</p>
<pre><code>with(GraphTheory):
graphsof5c := [NonIsomorphicGraphs(5, 1..5,output = graphs, outputform = graph)]:
DrawGraph~(graphsof5c,size=[300,300],stylesheet=[vertexborder=false,vertexpadding=20,edgecolor = "Blue",
vertexcolor="Gold"])
</code></pre>
<p>My points are less than 60 points, I can’t upload
corresponding pictures, sorry.</p>
https://ask.sagemath.org/question/54381/how-to-put-the-drawing-of-graphs-in-a-matrix-or-list/?answer=54382#post-id-54382I think that the `graphs_list.show_graphs` is the function you are looking for. Using the notation from above you can execute
```
sage: graphs_list.show_graphs(glist)
```
This will display the graphs in `glist` in blocks of at most 20 graphs. Further details at the user [manual](https://doc.sagemath.org/html/en/reference/graphs/sage/graphs/graph_list.html#sage.graphs.graph_list.show_graphs).
EDIT: Updated link formatting, link not rendering correctly.Wed, 25 Nov 2020 13:19:11 +0100https://ask.sagemath.org/question/54381/how-to-put-the-drawing-of-graphs-in-a-matrix-or-list/?answer=54382#post-id-54382Comment by licheng for <p>I think that the <code>graphs_list.show_graphs</code> is the function you are looking for. Using the notation from above you can execute</p>
<p><code>
sage: graphs_list.show_graphs(glist)
</code></p>
<p>This will display the graphs in <code>glist</code> in blocks of at most 20 graphs. Further details at the user <a href="https://doc.sagemath.org/html/en/reference/graphs/sage/graphs/graph_list.html#sage.graphs.graph_list.show_graphs">manual</a>.</p>
<p>EDIT: Updated link formatting, link not rendering correctly.</p>
https://ask.sagemath.org/question/54381/how-to-put-the-drawing-of-graphs-in-a-matrix-or-list/?comment=54416#post-id-54416thanks for your help! it looks good!Fri, 27 Nov 2020 14:42:12 +0100https://ask.sagemath.org/question/54381/how-to-put-the-drawing-of-graphs-in-a-matrix-or-list/?comment=54416#post-id-54416