ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 10 Jan 2018 07:00:59 -0600Generating plane triangulationshttps://ask.sagemath.org/question/10851/generating-plane-triangulations/Does sage have a function that generates plane triangulations? Something like PLANTRI? If not, is it possible to use plantri from within sage and how?
Thank youhbmSat, 21 Dec 2013 07:22:30 -0600https://ask.sagemath.org/question/10851/Drawing a planar multigraph with loopshttps://ask.sagemath.org/question/40548/drawing-a-planar-multigraph-with-loops/ I would like to draw a planar graph with multiple edges and loops in Sage. Unfortunately, the default algorithm draws may intersecting edges and Sage is unable to compute an embedding for graphs with loops multiple edges.
Fortunately I know a planar embedding of this graph, so I tried using the `set_embedding` method, but it doesn't seem to work, either. If I only list a vertice's the neighbours, omitting their multiplicities, Sage complains that the list is shorter than the vertice's degree, while if I include multiple copies of each neighbour according to multiplicity, then Sage complains that elements of the list aren't unique.
Is there a way to achieve what I need?A.P.Wed, 10 Jan 2018 07:00:59 -0600https://ask.sagemath.org/question/40548/How do I get the external face of a planar embedded graph?https://ask.sagemath.org/question/33363/how-do-i-get-the-external-face-of-a-planar-embedded-graph/ First of all I am new to Sage and Python.
I need to get the external face a planar embedding and I immagined that it is always the first element returned by the function faces().
But in this example it seems to change. See the first and the second run.
Is it something about the function faces() or an error in this program?
print ("--- Create a graph")
G = Graph(sparse=True)
G.add_edge(1,2,"1-2")
G.add_edge(2,3,"2-3")
G.add_edge(3,4,"3-4")
G.add_edge(4,5,"4-5")
G.add_edge(5,1,"5-1")
G.add_edge(1,6,"1-6")
G.add_edge(2,10,"2-10")
G.add_edge(3,12,"3-12")
G.add_edge(4,11,"4-11")
G.add_edge(5,7,"5-7")
G.add_edge(6,7,"6-7")
G.add_edge(6,8,"6-8")
G.add_edge(8,10,"8-10")
G.add_edge(10,12,"10-12")
G.add_edge(12,11,"12-11")
G.add_edge(7,9,"7-9")
G.add_edge(8,9,"8-9")
G.add_edge(9,11,"9-11")
print ("--- Embed on a plane")
void = G.layout(layout = "planar", save_pos = True)
G.plot()
# Kempe reduction: for each loop remove an edge from faces <= F5
#
while len(G.faces()) > 2:
print ("Number of faces: ", len(G.faces()))
# Remove the external face. Is it always faces[0]???
#
faces = G.faces()
externalFace = faces[0]
facesWithoutTheExternalFace = copy(faces)
facesWithoutTheExternalFace.remove(externalFace)
print ("faces: ", faces)
print ("externalFace: ", externalFace)
print ("facesWithoutTheExternalFace: ", facesWithoutTheExternalFace)
# Find the fist face [0] with len <= 5. It always exists: unavoidable set
#
faceToReduce = [x for x in facesWithoutTheExternalFace if len(x) <= 5][0]
print ("Face <= 5: ", faceToReduce)
# Find the first edge of the faceToReduce that is not on an edge on the external face
#
edgeToRemove = [x for x in faceToReduce if not x in externalFace][0]
print ("edgeToRemove: ", edgeToRemove)
verticesToRemove = G.get_vertices(edgeToRemove)
print ("verticesToRemove ", verticesToRemove)
G.delete_edge(edgeToRemove)
neighborsOfTheFirstVertex = G.neighbors(verticesToRemove.keys()[0])
neighborsOfTheSecondVertex = G.neighbors(verticesToRemove.keys()[1])
print ("neighborsOfTheFirstVertex = ", neighborsOfTheFirstVertex)
print ("neighborsOfTheSecondVertex = ", neighborsOfTheSecondVertex)
G.delete_vertices(verticesToRemove)
G.add_edge(neighborsOfTheFirstVertex[0], neighborsOfTheFirstVertex[1])
G.add_edge(neighborsOfTheSecondVertex[0], neighborsOfTheSecondVertex[1])
G.plot()stefanuttiWed, 11 May 2016 03:44:18 -0500https://ask.sagemath.org/question/33363/embed planar graph with prescribed outer facehttps://ask.sagemath.org/question/10900/embed-planar-graph-with-prescribed-outer-face/I am trying to ask the second part of [this question](http://ask.sagemath.org/question/3394/combinatorial-data-for-planar-graph).
Say I have a graph
g=Graph({'a': ['b', 'c', 'd', 'e'], 'c': ['a', 'b', 'g', 'f', 'd'], 'b': ['a','e', 'f', 'g', 'c'], 'e': ['a', 'd', 'h', 'f', 'b'], 'd': ['a', 'c','f', 'h', 'e'], 'g': ['b', 'f', 'c'], 'f': ['b', 'e', 'h', 'd', 'c','g'], 'h': ['d', 'f', 'e']}
I would like to have a planar embedding of the graph with the `['a','e','b']` as an outer face. How could that be done?
I have been reading on `set_planar_positions()`, `layout_planar()` and `plot(layout='planar')` and I am pretty confused.
mfSat, 11 Jan 2014 05:57:47 -0600https://ask.sagemath.org/question/10900/Combinatorial 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)
mfFri, 10 Jan 2014 09:15:39 -0600https://ask.sagemath.org/question/10902/Sage and planar graphshttps://ask.sagemath.org/question/7904/sage-and-planar-graphs/How can I compute the faces of a planar embedding of a planar graph? And how to compute the dual of a plane graph?hbmTue, 17 Dec 2013 14:08:01 -0600https://ask.sagemath.org/question/7904/