circle_layout#
- graph_tool.draw.circle_layout(g, order=None, radius=1.0, pos=None)[git][source]#
Place the vertices on a circle.
- Parameters:
- g
Graph 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.- radius
float(optional, default:1.) Radius of the circle.
- pos
VertexPropertyMap(optional, default:None) If provided, the positions will be stored in this property map.
- g
- Returns:
- pos
VertexPropertyMap The vertex positions.
- pos
See also
star_layoutVertices on a circle around a central vertex
shell_layoutVertices on concentric circles
spiral_layoutVertices along a spiral
sphere_layoutVertices 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") <...>
Circle layout of the karate club network, with the vertices in the spectral ordering of
vertex_ordering().#