code: def _construct_graph_from_list_dict(
      cls,
      edges,
      directed: bool = False,
      vertex_name_attr: str = "name",
  ):
      """Constructs a graph from a dict-of-lists representation.
  
      This function is used to construct a graph from a dictionary of
      lists. Other, non-list sequences (e.g. tuples) and lazy iterators are
      are accepted. For each key x, its corresponding value must be a sequence of
      multiple values y: the edge (x,y) will be created in the graph. x and y
      must be either one of:
  
        - two integers: the vertices with those ids will be connected
        - two strings: the vertices with those names will be connected
  
      If names are used, the order of vertices is not guaranteed, and each
      vertex will be given the vertex_name_attr attribute.
  
      @param edges: the dict of sequences describing the edges
      @param directed: whether to create a directed graph
      @param vertex_name_attr: vertex attribute that will store the names
  
      @returns: a Graph object
  
      Example:
  
      >>> mydict = {'apple': ['pear', 'peach'], 'pear': ['peach']}
      >>> g = Graph.ListDict(mydict)
  
      # The graph has three vertices with names and three edges connecting
      # each pair.
      """
      first_item = next(iter(edges), 0)
  
      if not isinstance(first_item, (int, str)):
          raise ValueError("Keys must be integers or strings")
  
      vertex_attributes = {}
      if isinstance(first_item, str):
          name_map = UniqueIdGenerator()
          edge_list = []
          for source, sequence in edges.items():
              source_id = name_map[source]
              edge_list.extend(
                  (source_id, name_map[target]) for target in sequence
              )
          vertex_attributes[vertex_name_attr] = name_map.values()
          n = len(name_map)
  
      else:
          edge_list = []
          n = -1
          for source, sequence in edges.items():
              n = max(n, source, *sequence)
              edge_list.extend(zip(repeat(source), sequence))
          n += 1
  
      # Construct the graph
      return cls(n, edge_list, directed, {}, vertex_attributes, {})
  
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 3 for calling a global function with example usage: _construct_graph_from_list_dict(cls, edges, directed, vertex_name_attr) and returns: cls