networkx.drawing.nx_agraph.from_agraph¶
-
from_agraph
(A, create_using=None)[source]¶ Return a NetworkX Graph or DiGraph from a PyGraphviz graph.
Parameters: - A (PyGraphviz AGraph) – A graph created with PyGraphviz
- create_using (NetworkX graph class instance) – The output is created using the given graph class instance
Examples
>>> K5 = nx.complete_graph(5) >>> A = nx.nx_agraph.to_agraph(K5) >>> G = nx.nx_agraph.from_agraph(A) >>> G = nx.nx_agraph.from_agraph(A)
Notes
The Graph G will have a dictionary G.graph_attr containing the default graphviz attributes for graphs, nodes and edges.
Default node attributes will be in the dictionary G.node_attr which is keyed by node.
Edge attributes will be returned as edge data in G. With edge_attr=False the edge data will be the Graphviz edge weight attribute or the value 1 if no edge weight attribute is found.