planar_layout

Contents

planar_layout#

graph_tool.draw.planar_layout(g, pos=None)[git][source]#

Performs a canonical layout of a planar graph.

Parameters:
gGraph

Planar graph to be used.

posVertexPropertyMap (optional, default: None)

Vector vertex property maps where the coordinates should be stored.

Returns:
posVertexPropertyMap

A vector-valued vertex property map with the coordinates of the vertices.

See also

graph_tool.structure.is_planar

Test whether the graph is planar

sfdp_layout

Multilevel force-directed layout

stress_layout

Layout 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

[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")
<...>
../_images/lattice-planar.png

Straight-line drawing of planar graph (a 2D square lattice).#