star_layout

Contents

star_layout#

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

Place one vertex at the center and the others on a circle around it.

Parameters:
gGraph

Graph to be used.

centerint or Vertex (optional, default: None)

The central vertex. If not given, the first vertex of order is used.

orderiterable of int (optional, default: None)

The vertices in their order around the circle (the center may be included, and is then skipped). 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

circle_layout

Vertices on a circle

shell_layout

Vertices on concentric circles

radial_tree_layout

Radial layout of a tree

Notes

The center is placed at the origin, and the other vertices at equal angles, counterclockwise from the positive \(x\) axis: the \(k\)-th of the \(n\) other 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.star_layout(g, center=33)
>>> print(pos[33].a, pos[0].a)
[0. 0.] [1. 0.]
>>> gt.graph_draw(g, pos=pos, output="star-layout-karate.pdf")
<...>
../_images/star-layout-karate.png

Star layout of the karate club network, with vertex 33 at the center and the other vertices in the order of their indices.#