code: def _write_graph_to_file(graph, f, format=None, *args, **kwds):
      """Unified writing function for graphs.
  
      This method tries to identify the format of the graph given in
      the first parameter (based on extension) and calls the corresponding
      writer method.
  
      The remaining arguments are passed to the writer method without
      any changes.
  
      @param f: the file containing the graph to be saved
      @param format: the format of the file (if one wants to override the
        format determined from the filename extension, or the filename itself
        is a stream). C{None} means auto-detection. Possible values are:
  
          - C{"adjacency"}: adjacency matrix format
  
          - C{"dimacs"}: DIMACS format
  
          - C{"dot"}, C{"graphviz"}: GraphViz DOT format
  
          - C{"edgelist"}, C{"edges"} or C{"edge"}: numeric edge list format
  
          - C{"gml"}: GML format
  
          - C{"graphml"} and C{"graphmlz"}: standard and gzipped GraphML
            format
  
          - C{"gw"}, C{"leda"}, C{"lgr"}: LEDA native format
  
          - C{"lgl"}: LGL format
  
          - C{"ncol"}: NCOL format
  
          - C{"net"}, C{"pajek"}: Pajek format
  
          - C{"pickle"}, C{"picklez"}: standard and gzipped Python pickled
            format
  
          - C{"svg"}: SVG format
  
      @raises IOError: if the file format can't be identified and
        none was given.
      """
      if isinstance(f, os.PathLike):
          f = str(f)
      if format is None:
          format = _identify_format(f)
      try:
          writer = graph._format_mapping[format][1]
      except (KeyError, IndexError):
          raise IOError(
              "unknown file format: %s" % str(format)
          ) from None
      if writer is None:
          raise IOError(
              "no writer method for file format: %s" % str(format)
          )
      writer = getattr(graph, writer)
      return writer(f, *args, **kwds)
  
file_path: python-igraph/src/igraph/io/files.py
imports: import gzip
  import os
  from shutil import copyfileobj
  from warnings import warn
  from igraph._igraph import GraphBase
  from igraph.utils import named_temporary_file
label_desc: Use image node_id 13 for calling a global function with example usage: _write_graph_to_file(graph, f, format) and returns: writer