NetworkX

Previous topic

networkx.draw_graphviz

Next topic

networkx.to_agraph

Quick search

networkx.from_agraph

from_agraph(A, create_using=None)

Return a NetworkX Graph or DiGraph from a pygraphviz graph.

>>> G=nx.complete_graph(5)
>>> A=nx.to_agraph(G)
>>> X=nx.from_agraph(A)

The Graph X will have a dictionary X.graph_attr containing the default graphviz attributes for graphs, nodes and edges.

Default node attributes will be in the dictionary X.node_attr which is keyed by node.

Edge attributes will be returned as edge data in the graph X.

If you want a Graph with no attributes attached instead of an XGraph with attributes use

>>> G=nx.Graph(X)