Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

to_networkx_graph

to_networkx_graph(data, create_using=None, multigraph_input=False)[source]

Make a NetworkX graph from a known data structure.

The preferred way to call this is automatically from the class constructor

>>> d={0: {1: {'weight':1}}} # dict-of-dicts single edge (0,1)
>>> G=nx.Graph(d)

instead of the equivalent

>>> G=nx.from_dict_of_dicts(d)
Parameters:

data : a object to be converted

Current known types are:

any NetworkX graph dict-of-dicts dist-of-lists list of edges numpy matrix numpy ndarray scipy sparse matrix pygraphviz agraph

create_using : NetworkX graph

Use specified graph for result. Otherwise a new graph is created.

multigraph_input : bool (default False)

If True and data is a dict_of_dicts, try to create a multigraph assuming dict_of_dict_of_lists. If data and create_using are both multigraphs then create a multigraph from a multigraph.