Warning

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

networkx.convert.from_dict_of_dicts

from_dict_of_dicts(d, create_using=None, multigraph_input=False)[source]

Returns a graph from a dictionary of dictionaries.

Parameters:
  • d (dictionary of dictionaries) – A dictionary of dictionaries adjacency representation.
  • 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)) – When True, the values of the inner dict are assumed to be containers of edge data for multiple edges. Otherwise this routine assumes the edge data are singletons.

Examples

>>> dod = {0: {1: {'weight': 1}}} # single edge (0,1)
>>> G = nx.from_dict_of_dicts(dod)

or

>>> G = nx.Graph(dod) # use Graph constructor