bfs_layout#
- bfs_layout(G, start, *, align='vertical', scale=1, center=None)[source]#
Position nodes according to breadth-first search algorithm.
- Parameters:
- GNetworkX graph
A position will be assigned to every node in G.
- startnode in
G
Starting node for bfs
- 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.
Examples
>>> G = nx.path_graph(4) >>> pos = nx.bfs_layout(G, 0)