planar_layout#
- graph_tool.draw.planar_layout(g, pos=None)[git][source]#
Performs a canonical layout of a planar graph.
- Parameters:
- g
Graph Planar graph to be used.
- pos
VertexPropertyMap(optional, default:None) Vector vertex property maps where the coordinates should be stored.
- g
- Returns:
- pos
VertexPropertyMap A vector-valued vertex property map with the coordinates of the vertices.
- pos
See also
graph_tool.structure.is_planarTest whether the graph is planar
sfdp_layoutMultilevel force-directed layout
stress_layoutLayout by stress majorization
Notes
This algorithm has complexity \(O(V + E)\).
Graphs with fewer than three vertices are placed on a horizontal line.
Parallel implementation.
If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.
References
[straight-line-boost][chrobak-linear-1995]M. Chrobak, T. Payne, “A Linear-time Algorithm for Drawing a Planar Graph on the Grid”, Information Processing Letters 54: 241-246, (1995), DOI: 10.1016/0020-0190(95)00020-D [sci-hub, @tor]
Examples
>>> g = gt.lattice([10, 10]) >>> pos = gt.planar_layout(g) >>> gt.graph_draw(g, pos=pos, output="lattice-planar.pdf") <...>
Straight-line drawing of planar graph (a 2D square lattice).#