#

Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

#

networkx.drawing.layout.multipartite_layout

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

Position nodes in layers of straight lines.

Parameters
  • G (NetworkX graph or list of nodes) – A position will be assigned to every node in G.

  • subset_key (string (default=’subset’)) – Key of node data to be used as layer subset.

  • align (string (default=’vertical’)) – The alignment of nodes. Vertical or horizontal.

  • scale (number (default: 1)) – Scale factor for positions.

  • center (array-like or None) – Coordinate pair around which to center the layout.

Returns

pos – A dictionary of positions keyed by node.

Return type

dict

Examples

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

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.