ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 30 Oct 2013 06:35:16 -0500Drawing a graph - fixing its layouthttp://ask.sagemath.org/question/10675/drawing-a-graph-fixing-its-layout/Hello!
I would like to draw a simple graph $G$ and its complement $\overline{G}.$ I was asked to make the drawing such that it is evident that the drawings are complementary. More precisely I was advised to draw $G$ and $\overline{G}$ such that the coordinates of the vertices of $G$ are the same as the one for $\overline{G}.$
What would be an easy way to accomplish this in Sage?
Thank youWed, 30 Oct 2013 06:29:11 -0500http://ask.sagemath.org/question/10675/drawing-a-graph-fixing-its-layout/Answer by Nathann for <p>Hello!</p>
<p>I would like to draw a simple graph $G$ and its complement $\overline{G}.$ I was asked to make the drawing such that it is evident that the drawings are complementary. More precisely I was advised to draw $G$ and $\overline{G}$ such that the coordinates of the vertices of $G$ are the same as the one for $\overline{G}.$</p>
<p>What would be an easy way to accomplish this in Sage?</p>
<p>Thank you</p>
http://ask.sagemath.org/question/10675/drawing-a-graph-fixing-its-layout/?answer=15630#post-id-15630With `g.plot(save_pos = True)` the layout used by Sage in the plot is saved in `g`. You can obtain it by doing `g.get_pos()` and give them to another graph with `h.set_pos(g.get_pos())`.
sage: g = graphs.KneserGraph(5,2)
sage: g.show(save_pos=True)
sage: g2 = g.complement()
sage: g2.set_pos(g.get_pos())
sage: g2.show()
Wed, 30 Oct 2013 06:35:16 -0500http://ask.sagemath.org/question/10675/drawing-a-graph-fixing-its-layout/?answer=15630#post-id-15630