planar_faces#
- graph_tool.structure.planar_faces(g, edges=False)[git][source]#
Return the faces of a planar embedding of the graph.
- Parameters:
- g
Graph Graph to be used (the edge directions are ignored).
- edges
bool(optional, default:False) If
True, the faces are returned as sequences of edge indices instead of vertices.
- g
- Returns:
- faces
listofnumpy.ndarrayorNone The vertices (or edges) around every face, in cyclic order, or
Noneif the graph is not planar.
- faces
See also
is_planarPlanarity test and embedding
graph_tool.generation.make_maximal_planarMaximal planar supergraph
graph_tool.draw.planar_layoutStraight-line planar drawing
Notes
A planar embedding is found with the Boyer-Myrvold algorithm [boyer-cutting-2004], and its faces are traversed, in time \(O(V + E)\). By Euler’s formula, a connected planar graph has \(E - V + 2\) faces, including the outer face; a bridge appears twice along the face that contains it. Parallel edges and self-loops are ignored.
References
[boyer-cutting-2004]John M. Boyer and Wendy J. Myrvold, “On the cutting edge: simplified O(n) planarity by edge addition”, Journal of Graph Algorithms and Applications 8(3), 241-273 (2004), DOI: 10.7155/jgaa.00091 [sci-hub, @tor]
Examples
>>> g = gt.lattice([3, 3]) >>> faces = gt.planar_faces(g) >>> print(len(faces), sorted(len(f) for f in faces)) 5 [4, 4, 4, 4, 8]