multipartite_layout#

multipartite_layout(G, subset_key='subset', align='vertical', scale=1, center=None)[source]#

Position nodes in layers of straight lines.

Parameters:
GNetworkX graph or list of nodes

A position will be assigned to every node in G.

subset_keystring (default=’subset’)

Key of node data to be used as layer subset.

alignstring (default=’vertical’)

The alignment of nodes. Vertical or horizontal.

scalenumber (default: 1)

Scale factor for positions.

centerarray-like or None

Coordinate pair around which to center the layout.

Returns:
posdict

A dictionary of positions keyed by node.

Notes

This algorithm currently only works in two dimensions and does not try to minimize edge crossings.

Network does not need to be a complete multipartite graph. As long as nodes have subset_key data, they will be placed in the corresponding layers.

Examples

>>> G = nx.complete_multipartite_graph(28, 16, 10)
>>> pos = nx.multipartite_layout(G)