networkx.convert.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 (object to be converted) –
- Current known types are:
any NetworkX graph dict-of-dicts dict-of-lists container (e.g. set, list, tuple) of edges iterator (e.g. itertools.chain) that produces edges generator of edges Pandas DataFrame (row per edge) numpy matrix numpy ndarray scipy sparse matrix pygraphviz agraph
create_using (NetworkX graph constructor, optional (default=nx.Graph)) – Graph type to create. If graph instance, then cleared before populated.
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.