networkx.drawing.nx_pydot.pydot_layout¶
-
pydot_layout
(G, prog='neato', root=None, **kwds)[source]¶ Create node positions using
pydot
and Graphviz.Parameters: - G (Graph) – NetworkX graph to be laid out.
- prog (optional[str]) – Basename of the GraphViz command with which to layout this graph.
Defaults to
neato
: default GraphViz command for undirected graphs.
Returns: Dictionary of positions keyed by node.
Return type: Examples
>>> G = nx.complete_graph(4) >>> pos = nx.nx_pydot.pydot_layout(G) >>> pos = nx.nx_pydot.pydot_layout(G, prog='dot')
Notes
If you use complex node objects, they may have the same string representation and GraphViz could treat them as the same node. The layout may assign both nodes a single location. See Issue #1568 If this occurs in your case, consider relabeling the nodes just for the layout computation using something similar to:
H = nx.convert_node_labels_to_integers(G, label_attribute=’node_label’) H_layout = nx.nx_pydot.pydot_layout(G, prog=’dot’) G_layout = {H.nodes[n][‘node_label’]: p for n, p in H_layout.items()}