code: def read_dot(path):
      """Returns a NetworkX :class:`MultiGraph` or :class:`MultiDiGraph` from the
      dot file with the passed path.
  
      If this file contains multiple graphs, only the first such graph is
      returned. All graphs _except_ the first are silently ignored.
  
      Parameters
      ----------
      path : str or file
          Filename or file handle.
  
      Returns
      -------
      G : MultiGraph or MultiDiGraph
          A :class:`MultiGraph` or :class:`MultiDiGraph`.
  
      Notes
      -----
      Use `G = nx.Graph(nx.nx_pydot.read_dot(path))` to return a :class:`Graph` instead of a
      :class:`MultiGraph`.
      """
      import pydot
  
      data = path.read()
  
      # List of one or more "pydot.Dot" instances deserialized from this file.
      P_list = pydot.graph_from_dot_data(data)
  
      # Convert only the first such instance into a NetworkX graph.
      return from_pydot(P_list[0])
  
file_path: networkx/networkx/drawing/nx_pydot.py
imports: from locale import getpreferredencoding
  import networkx
  from networkx.utils import open_file
label_desc: Use image node_id 2 for calling a global function with example usage: read_dot(path) and returns: from_pydot