code: def to_dict_of_lists(G, nodelist=None):
      """Returns adjacency representation of graph as a dictionary of lists.
  
      Parameters
      ----------
      G : graph
         A NetworkX graph
  
      nodelist : list
         Use only nodes specified in nodelist
  
      Notes
      -----
      Completely ignores edge data for MultiGraph and MultiDiGraph.
  
      """
      if nodelist is None:
          nodelist = G
  
      d = {}
      for n in nodelist:
          d[n] = [nbr for nbr in G.neighbors(n) if nbr in nodelist]
      return d
  
file_path: networkx/networkx/convert.py
imports: import warnings
  from collections.abc import Collection, Generator, Iterator
  import networkx
label_desc: Use image node_id 2 for calling a global function with example usage: to_dict_of_lists(G, nodelist) and returns: d