code: def _construct_graph_from_adjacency_file(
      cls, f, sep=None, comment_char="#", attribute=None, *args, **kwds
  ):
      """Constructs a graph based on an adjacency matrix from the given file.
  
      Additional positional and keyword arguments not mentioned here are
      passed intact to L{Graph.Adjacency}.
  
      @param f: the name of the file to be read or a file object
      @param sep: the string that separates the matrix elements in a row.
        C{None} means an arbitrary sequence of whitespace characters.
      @param comment_char: lines starting with this string are treated
        as comments.
      @param attribute: an edge attribute name where the edge weights are
        stored in the case of a weighted adjacency matrix. If C{None},
        no weights are stored, values larger than 1 are considered as
        edge multiplicities.
      @return: the created graph"""
      if isinstance(f, str):
          f = open(f)
  
      matrix, ri = [], 0
      for line in f:
          line = line.strip()
          if len(line) == 0:
              continue
          if line.startswith(comment_char):
              continue
          row = [float(x) for x in line.split(sep)]
          matrix.append(row)
          ri += 1
  
      f.close()
  
      if attribute is None:
          graph = cls.Adjacency(matrix, *args, **kwds)
      else:
          graph, weights = cls._Weighted_Adjacency(
              matrix, *args, **kwds
          )
          graph.es[attribute] = weights
  
      return graph
  
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 2 for calling a global function with example usage: _construct_graph_from_adjacency_file(cls, f, sep, comment_char, attribute) and returns: graph