circle_layout

Contents

circle_layout#

graph_tool.draw.circle_layout(g, order=None, radius=1.0, pos=None)[git][source]#

Place the vertices on a circle.

Parameters:
gGraph

Graph to be used.

orderiterable of int (optional, default: None)

The vertices in their order around the circle (e.g. from vertex_ordering(), to shorten the edges). If not given, the order of the vertex indices is used.

radiusfloat (optional, default: 1.)

Radius of the circle.

posVertexPropertyMap (optional, default: None)

If provided, the positions will be stored in this property map.

Returns:
posVertexPropertyMap

The vertex positions.

See also

star_layout

Vertices on a circle around a central vertex

shell_layout

Vertices on concentric circles

spiral_layout

Vertices along a spiral

sphere_layout

Vertices on a sphere

Notes

The vertices are placed at equal angles, counterclockwise from the positive \(x\) axis: the \(k\)-th of \(n\) vertices in the order, with \(k = 0, \dots, n - 1\), is placed at

\[\boldsymbol x_k = R\left(\cos\frac{2\pi k}{n}, \sin\frac{2\pi k}{n}\right),\]

where \(R\) is radius. The edges are ignored.

Examples

>>> g = gt.collection.data["karate"]
>>> pos = gt.circle_layout(g)
>>> print(pos[0].a, pos[17].a)
[1. 0.] [-1.0...  1.2...e-16]

The vertices can also be placed in an ordering that reduces the bandwidth of the adjacency matrix, as in the figure below, which is obtained with

>>> pos = gt.circle_layout(g, order=gt.vertex_ordering(g, "spectral"))
>>> gt.graph_draw(g, pos=pos, output="circle-layout-karate.pdf")
<...>
../_images/circle-layout-karate.png

Circle layout of the karate club network, with the vertices in the spectral ordering of vertex_ordering().#