code: def from_dict_of_lists(d, create_using=None):
      """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
  
      """
      G = nx.empty_graph(0, create_using)
      G.add_nodes_from(d)
      if G.is_multigraph() and not G.is_directed():
          # a dict_of_lists can't show multiedges.  BUT for undirected graphs,
          # each edge shows up twice in the dict_of_lists.
          # So we need to treat this case separately.
          seen = {}
          for node, nbrlist in d.items():
              for nbr in nbrlist:
                  if nbr not in seen:
                      G.add_edge(node, nbr)
              seen[node] = 1  # don't allow reverse edge to show up
      else:
          G.add_edges_from(
              (
                  (node, nbr)
                  for node, nbrlist in d.items()
                  for nbr in nbrlist
              )
          )
      return G
  
file_path: networkx/networkx/convert.py
imports: import warnings
  from collections.abc import Collection, Generator, Iterator
  import networkx
label_desc: Use image node_id 3 for calling a global function with example usage: from_dict_of_lists(d, create_using) and returns: G