code: def _export_graph_to_list_dict(
      graph,
      use_vids: bool = True,
      sequence_constructor: callable = list,
      vertex_name_attr: str = "name",
  ):
      """Export graph to a dictionary of lists (or other sequences).
  
      This function is the reverse of Graph.ListDict.
  
      Example:
  
        >>> g = Graph.Full(3)
        >>> g.to_sequence_dict() -> {0: [1, 2], 1: [2]}
        >>> g.to_sequence_dict(sequence_constructor=tuple) -> {0: (1, 2), 1: (2,)}
        >>> g.vs['name'] = ['apple', 'pear', 'peach']
        >>> g.to_sequence_dict(use_vids=False)
        {'apple': ['pear', 'peach'], 'pear': ['peach']}
  
      @param use_vids: whether to label vertices in the output data
        structure by their ids or their vertex_name_attr attribute. If
        use_vids=False but vertices lack a vertex_name_attr attribute, an
        AttributeError is raised.
      @param sequence_constructor: constructor for the data structure
        to be used as values of the dictionary. The default (list) makes a dict
        of lists, with each list representing the neighbors of the vertex
        specified in the respective dictionary key.
      @param vertex_name_attr: only used with use_vids=False to choose what
        vertex attribute to use to name your vertices in the output data
        structure.
  
      @return: dictionary of sequences, keyed by vertices, with each value
        containing the neighbors of that vertex.
      """
      if not use_vids:
          if vertex_name_attr not in graph.vertex_attributes():
              raise AttributeError(
                  f"Vertices do not have a {vertex_name_attr} attribute"
              )
          vs_names = graph.vs[vertex_name_attr]
  
      # Temporary output data structure
      res = defaultdict(list)
  
      for edge in graph.es:
          source, target = edge.tuple
  
          if not use_vids:
              source = vs_names[source]
              target = vs_names[target]
  
          res[source].append(target)
  
      res = {key: sequence_constructor(val) for key, val in res.items()}
      return res
  
file_path: python-igraph/src/igraph/io/objects.py
imports: from typing import Union, Sequence
  from collections import defaultdict
  from itertools import repeat
  from warnings import warn
  from igraph.datatypes import UniqueIdGenerator
label_desc: Use image node_id 8 for calling a global function with example usage: _export_graph_to_list_dict(graph, use_vids, sequence_constructor, vertex_name_attr) and returns: res