code: def _add_vertices(graph, n, attributes=None):
      """Adds some vertices to the graph.
  
      Note that if C{n} is a sequence of strings, indicating the names of the
      new vertices, and attributes has a key C{name}, the two conflict. In
      that case the attribute will be applied.
  
      @param n: the number of vertices to be added, or the name of a single
        vertex to be added, or a sequence of strings, each corresponding to the
        name of a vertex to be added. Names will be assigned to the C{name}
        vertex attribute.
      @param attributes: dict of sequences, all of length equal to the
        number of vertices to be added, containing the attributes of the new
        vertices. If n is a string (so a single vertex is added), then the
        values of this dict are the attributes themselves, but if n=1 then
        they have to be lists of length 1.
      """
      if isinstance(n, str):
          # Adding a single vertex with a name
          m = graph.vcount()
          result = GraphBase.add_vertices(graph, 1)
          graph.vs[m]["name"] = n
          if attributes is not None:
              for key, val in attributes.items():
                  graph.vs[m][key] = val
      elif hasattr(n, "__iter__"):
          m = graph.vcount()
          if not hasattr(n, "__len__"):
              names = list(n)
          else:
              names = n
          result = GraphBase.add_vertices(graph, len(names))
          if len(names) > 0:
              graph.vs[m:]["name"] = names
              if attributes is not None:
                  for key, val in attributes.items():
                      graph.vs[m:][key] = val
      else:
          result = GraphBase.add_vertices(graph, n)
          if (attributes is not None) and (n > 0):
              m = graph.vcount() - n
              for key, val in attributes.items():
                  graph.vs[m:][key] = val
      return result
  
file_path: python-igraph/src/igraph/basic.py
imports: from igraph._igraph import GraphBase
  from igraph.seq import EdgeSeq
  from igraph.utils import deprecated
label_desc: Use image node_id 4 for calling a global function with example usage: _add_vertices(graph, n, attributes) and returns: result