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.Sat, 11 Jan 2014 05:48:52 -0600Combinatorial data for planar graphhttps://ask.sagemath.org/question/10902/combinatorial-data-for-planar-graph/I am trying to get sage working with planar embedded graphs. The answer [here](http://ask.sagemath.org/question/3340/generating-plane-triangilation) was quite helpful, but I have a few more questions.
1. Is there a way to get represention of the embedding into sage? The graph6 format forgets the embedding (see the [documentation of plantri](http://cs.anu.edu.au/~bdm/plantri/plantri-guide.txt)).
2. Can I presribe the outer face of my embedding when I plot a Graph in sage using .plot(layout='planar')?
Ideally, for an embedded graph, I would like to obtain something like an oriented outer face and a list of oriented inner faces. For example for the graph below I want to have
inner_faces=[[2,0,3],[0,1,4,5,3],[1,2,4],[2,3,5],[2,5,4]]
outer_face=[0,1,2]
![graph](http://imgur.com/L5qm91e.png)
Fri, 10 Jan 2014 09:15:39 -0600https://ask.sagemath.org/question/10902/combinatorial-data-for-planar-graph/Answer by Nathann for <p>I am trying to get sage working with planar embedded graphs. The answer <a href="http://ask.sagemath.org/question/3340/generating-plane-triangilation">here</a> was quite helpful, but I have a few more questions. </p>
<ol>
<li><p>Is there a way to get represention of the embedding into sage? The graph6 format forgets the embedding (see the <a href="http://cs.anu.edu.au/~bdm/plantri/plantri-guide.txt">documentation of plantri</a>).</p></li>
<li><p>Can I presribe the outer face of my embedding when I plot a Graph in sage using .plot(layout='planar')?</p></li>
</ol>
<p>Ideally, for an embedded graph, I would like to obtain something like an oriented outer face and a list of oriented inner faces. For example for the graph below I want to have</p>
<pre><code>inner_faces=[[2,0,3],[0,1,4,5,3],[1,2,4],[2,3,5],[2,5,4]]
outer_face=[0,1,2]
</code></pre>
<p><img alt="graph" src="http://imgur.com/L5qm91e.png"/></p>
https://ask.sagemath.org/question/10902/combinatorial-data-for-planar-graph/?answer=15907#post-id-15907Helloooooo !!
sage: g = graphs.IcosahedralGraph()
sage: g.is_planar(set_embedding=True)
True
sage: g.get_embedding()
{0: [1, 5, 11, 7, 8],
1: [8, 2, 6, 5, 0],
2: [8, 9, 3, 6, 1],
3: [2, 9, 10, 4, 6],
4: [3, 10, 11, 5, 6],
5: [0, 1, 6, 4, 11],
6: [1, 2, 3, 4, 5],
7: [0, 11, 10, 9, 8],
8: [0, 7, 9, 2, 1],
9: [8, 7, 10, 3, 2],
10: [9, 7, 11, 4, 3],
11: [0, 5, 4, 10, 7]}
sage: g.trace_faces()
[[(10, 11), (11, 7), (7, 10)],
[(6, 4), (4, 3), (3, 6)],
[(5, 6), (6, 1), (1, 5)],
[(2, 8), (8, 1), (1, 2)],
[(9, 8), (8, 2), (2, 9)],
[(8, 0), (0, 1), (1, 8)],
[(3, 2), (2, 6), (6, 3)],
[(0, 7), (7, 11), (11, 0)],
[(2, 1), (1, 6), (6, 2)],
[(8, 9), (9, 7), (7, 8)],
[(4, 10), (10, 3), (3, 4)],
[(5, 4), (4, 6), (6, 5)],
[(11, 4), (4, 5), (5, 11)],
[(10, 4), (4, 11), (11, 10)],
[(9, 3), (3, 10), (10, 9)],
[(7, 0), (0, 8), (8, 7)],
[(11, 5), (5, 0), (0, 11)],
[(10, 7), (7, 9), (9, 10)],
[(2, 3), (3, 9), (9, 2)],
[(5, 1), (1, 0), (0, 5)]]
If you want the faces as list of vertices instead of edges, you can do
sage: map(lambda x:[y[0] for y in x],g.trace_faces())
Aaaaand I have no idea of what `layout=planar` does,sorry :-)Sat, 11 Jan 2014 00:27:12 -0600https://ask.sagemath.org/question/10902/combinatorial-data-for-planar-graph/?answer=15907#post-id-15907Comment by mf for <p>Helloooooo !!</p>
<pre><code>sage: g = graphs.IcosahedralGraph()
sage: g.is_planar(set_embedding=True)
True
sage: g.get_embedding()
{0: [1, 5, 11, 7, 8],
1: [8, 2, 6, 5, 0],
2: [8, 9, 3, 6, 1],
3: [2, 9, 10, 4, 6],
4: [3, 10, 11, 5, 6],
5: [0, 1, 6, 4, 11],
6: [1, 2, 3, 4, 5],
7: [0, 11, 10, 9, 8],
8: [0, 7, 9, 2, 1],
9: [8, 7, 10, 3, 2],
10: [9, 7, 11, 4, 3],
11: [0, 5, 4, 10, 7]}
sage: g.trace_faces()
[[(10, 11), (11, 7), (7, 10)],
[(6, 4), (4, 3), (3, 6)],
[(5, 6), (6, 1), (1, 5)],
[(2, 8), (8, 1), (1, 2)],
[(9, 8), (8, 2), (2, 9)],
[(8, 0), (0, 1), (1, 8)],
[(3, 2), (2, 6), (6, 3)],
[(0, 7), (7, 11), (11, 0)],
[(2, 1), (1, 6), (6, 2)],
[(8, 9), (9, 7), (7, 8)],
[(4, 10), (10, 3), (3, 4)],
[(5, 4), (4, 6), (6, 5)],
[(11, 4), (4, 5), (5, 11)],
[(10, 4), (4, 11), (11, 10)],
[(9, 3), (3, 10), (10, 9)],
[(7, 0), (0, 8), (8, 7)],
[(11, 5), (5, 0), (0, 11)],
[(10, 7), (7, 9), (9, 10)],
[(2, 3), (3, 9), (9, 2)],
[(5, 1), (1, 0), (0, 5)]]
</code></pre>
<p>If you want the faces as list of vertices instead of edges, you can do</p>
<pre><code>sage: map(lambda x:[y[0] for y in x],g.trace_faces())
</code></pre>
<p>Aaaaand I have no idea of what <code>layout=planar</code> does,sorry :-)</p>
https://ask.sagemath.org/question/10902/combinatorial-data-for-planar-graph/?comment=16457#post-id-16457thanks, I'll ask about planarity in a seperate question..Sat, 11 Jan 2014 05:48:52 -0600https://ask.sagemath.org/question/10902/combinatorial-data-for-planar-graph/?comment=16457#post-id-16457