bipartite_layout¶
- bipartite_layout(G, nodes, align='vertical', scale=1, center=None, aspect_ratio=1.3333333333333333)[source]¶
Position nodes in two straight lines.
- Parameters
- GNetworkX graph or list of nodes
A position will be assigned to every node in G.
- nodeslist or container
Nodes in one node set of the bipartite graph. This set will be placed on left or top.
- 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.
- aspect_rationumber (default=4/3):
The ratio of the width to the height of 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.
Examples
>>> G = nx.bipartite.gnmk_random_graph(3, 5, 10, seed=123) >>> top = nx.bipartite.sets(G)[0] >>> pos = nx.bipartite_layout(G, top)