shell_layout

Contents

shell_layout#

graph_tool.draw.shell_layout(g, shells=None, rotate=None, scale=1.0, pos=None)[git][source]#

Place the vertices on concentric circles.

Parameters:
gGraph

Graph to be used.

shellslist of iterables of int, or VertexPropertyMap (optional, default: None)

The vertices of every shell, from the innermost one, in their order around the circle; or an integer vertex property map with the shell of every vertex, ordered by value, with the vertices of the same shell in the order of their indices. If not given, all vertices are on one shell.

rotatefloat (optional, default: None)

Angle by which every shell is rotated with respect to the previous one. If not given, \(\pi/S\) is used, where \(S\) is the number of shells.

scalefloat (optional, default: 1.)

Radius of the outermost shell.

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

star_layout

Vertices on a circle around a central vertex

radial_tree_layout

Radial layout of a tree

Notes

The \(j\)-th of the \(n_s\) vertices of shell \(s = 1, \dots, S\), with \(j = 0, \dots, n_s - 1\), is placed at

\[\boldsymbol x_{s,j} = r_s\left(\cos\theta_{s,j}, \sin\theta_{s,j}\right), \qquad \theta_{s,j} = \frac{2\pi j}{n_s} + s\alpha,\]

where \(\alpha\) is rotate, and the radius is \(r_s = s\,c/S\), where \(c\) is scale, or \(r_s = (s - 1)c/(S - 1)\) if the first shell has a single vertex (and \(S > 1\)), which is then placed at the center, so that the outermost shell has radius \(c\) in both cases. The edges are ignored.

Examples

>>> g = gt.collection.data["karate"]
>>> d = gt.shortest_distance(g, source=0)
>>> pos = gt.shell_layout(g, shells=d)
>>> gt.graph_draw(g, pos=pos, output="karate-shell.pdf")
<...>
../_images/karate-shell.png

Shell layout of the karate club network, with the shells given by the distances from vertex 0.#