planar_layout

Contents

planar_layout#

graph_tool.draw.planar_layout(g, pos=None)[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.

Notes

This algorithm has complexity \(O(V + E)\).

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).#