ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 17 Mar 2017 14:58:33 -0500Plotting poset with vertices replaced by graph plotshttps://ask.sagemath.org/question/36930/plotting-poset-with-vertices-replaced-by-graph-plots/Hello ask.sagemath! I'd like to graph a poset of all connected graphs on $4$ vertices with the relation of $\subset$.
So far I can either draw all such graph using
L = filter(lambda g : g.is_connected(), graphs(4));
graphs_list.show_graphs(L)
Or draw a Poset with
Poset((["a","b","c"],[["a","c"],["b","c"]])).show();
But I can't combine them to, say, have
g1=Graph([(1,2),(2,3)]);
g2=Graph([(1,2),(1,3)]);
g3=Graph(networkx.complete_graph(3));
Poset([g1,g2,g3],[[g1,g3],[g2,g3]).show();
Is there a way to draw a poset where the vertices are also drawn to be graphs?
Thank you for your help!Mon, 13 Mar 2017 13:28:20 -0500https://ask.sagemath.org/question/36930/plotting-poset-with-vertices-replaced-by-graph-plots/Answer by FrédéricC for <p>Hello ask.sagemath! I'd like to graph a poset of all connected graphs on $4$ vertices with the relation of $\subset$. <br>
So far I can either draw all such graph using</p>
<pre><code>L = filter(lambda g : g.is_connected(), graphs(4));
graphs_list.show_graphs(L)
</code></pre>
<p>Or draw a Poset with</p>
<pre><code>Poset((["a","b","c"],[["a","c"],["b","c"]])).show();
</code></pre>
<p>But I can't combine them to, say, have</p>
<pre><code>g1=Graph([(1,2),(2,3)]);
g2=Graph([(1,2),(1,3)]);
g3=Graph(networkx.complete_graph(3));
Poset([g1,g2,g3],[[g1,g3],[g2,g3]).show();
</code></pre>
<p>Is there a way to draw a poset where the vertices are also drawn to be graphs?</p>
<p>Thank you for your help!</p>
https://ask.sagemath.org/question/36930/plotting-poset-with-vertices-replaced-by-graph-plots/?answer=36968#post-id-36968Not very nice, but this sort of works. First install ''dot2tex'' using ''sage -i dot2tex''. Then
sage: g1 = Graph([(1,2),(2,3)], immutable=True)
sage: g2 = Graph([(1,2),(1,3)], immutable=True)
You can also do this like that : "g = g.copy(immutable=True)"
sage: G = DiGraph({g1:[g2]})
sage: G.set_latex_options(format='dot2tex')
sage: view(G)
This outputs a pdf file.
You can then try to play with the options to get a better layout.Fri, 17 Mar 2017 14:58:33 -0500https://ask.sagemath.org/question/36930/plotting-poset-with-vertices-replaced-by-graph-plots/?answer=36968#post-id-36968