code: def _graphmethod(func=None, name=None):
      """Auxiliary decorator
  
      This decorator allows some methods of L{VertexSeq} and L{EdgeSeq} to
      call their respective counterparts in L{Graph} to avoid code duplication.
  
      @param func: the function being decorated. This function will be
        called on the results of the original L{Graph} method.
        If C{None}, defaults to the identity function.
      @param name: the name of the corresponding method in L{Graph}. If
        C{None}, it defaults to the name of the decorated function.
      @return: the decorated function
      """
      # Delay import to avoid cycles
      from igraph import Graph
  
      if name is None:
          name = func.__name__
      method = getattr(Graph, name)
  
      if callable(func):
  
          def decorated(*args, **kwds):
              self = args[0].graph
              return func(args[0], method(self, *args, **kwds))
  
      else:
  
          def decorated(*args, **kwds):
              self = args[0].graph
              return method(self, *args, **kwds)
  
      decorated.__name__ = name
      decorated.__doc__ = """Proxy method to L{Graph.%(name)s()}
  
  This method calls the C{%(name)s()} method of the L{Graph} class
  restricted to this sequence, and returns the result.
  
  @see: Graph.%(name)s() for details.
  """ % {
          "name": name
      }
  
      return decorated
  
file_path: python-igraph/src/igraph/seq.py
imports: import operator
  from igraph._igraph import EdgeSeq, VertexSeq
label_desc: Use image node_id 1 for calling a global function with example usage: _graphmethod(func, name) and returns: decorated, func, method