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_lists

from_dict_of_lists(d, create_using=None)[source]

Returns a graph from a dictionary of lists.

Parameters:
  • d (dictionary of lists) – A dictionary of lists adjacency representation.
  • create_using (NetworkX graph constructor, optional (default=nx.Graph)) – Graph type to create. If graph instance, then cleared before populated.

Examples

>>> dol = {0: [1]} # single edge (0,1)
>>> G = nx.from_dict_of_lists(dol)

or

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