NetworkX

Previous topic

networkx.from_scipy_sparse_matrix

Next topic

networkx.to_dict_of_lists

networkx.from_whatever

from_whatever(thing, create_using=None, multigraph_input=False)

Make a NetworkX graph from an known type.

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:

thing : 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 thing is a dict_of_dicts, try to create a multigraph assuming dict_of_dict_of_lists. If thing and create_using are both multigraphs then create a multigraph from a multigraph.