class_docstr: Generates random internet AS graphs.
class_docstr_tok: ["Generates","random","internet","AS","graphs","."]
docstr: Add a node and its customer transit edges to the graph.
  
  Parameters
  ----------
  i: object
      Identifier of the new node
  kind: string
      Type of the new node. Options are: 'M' for middle node, 'CP' for
      content provider and 'C' for customer.
  reg2prob: float
      Probability the new node can be in two different regions.
  avg_deg: float
      Average number of transit nodes of which node i is customer.
  t_edge_prob: float
      Probability node i establish a customer transit edge with a tier
      one (T) node
  
  Returns
  -------
  i: object
      Identifier of the new node
docstr_tok: ["Add","a","node","and","its","customer","transit","edges","to","the","graph",".","Parameters","--","--","--","--","--","i",":","object","Identifier","of","the","new","node","kind",":","string","Type","of","the","new","node",".","Options","are",":","'M","'","for","middle","node",",","'CP","'","for","content","provider","and","'","C","'","for","customer",".","reg2prob",":","float","Probability","the","new","node","can","be","in","two","different","regions",".","avg_deg",":","float","Average","number","of","transit","nodes","of","which","node","i","is","customer",".","t_edge_prob",":","float","Probability","node","i","establish","a","customer","transit","edge","with","a","tier","one","(","T",")","node","Returns","--","--","--","-","i",":","object","Identifier","of","the","new","node"]
code: def add_node(self, i, kind, reg2prob, avg_deg, t_edge_prob):
      """Add a node and its customer transit edges to the graph.
  
      Parameters
      ----------
      i: object
          Identifier of the new node
      kind: string
          Type of the new node. Options are: 'M' for middle node, 'CP' for
          content provider and 'C' for customer.
      reg2prob: float
          Probability the new node can be in two different regions.
      avg_deg: float
          Average number of transit nodes of which node i is customer.
      t_edge_prob: float
          Probability node i establish a customer transit edge with a tier
          one (T) node
  
      Returns
      -------
      i: object
          Identifier of the new node
      """
  
      regs = 1  # regions in which node resides
      if self.seed.random() < reg2prob:  # node is in two regions
          regs = 2
      node_options = set()
  
      self.G.add_node(i, type=kind, peers=0)
      self.customers[i] = set()
      self.providers[i] = set()
      self.nodes[kind].add(i)
      for r in self.seed.sample(list(self.regions), regs):
          node_options = node_options.union(self.regions[r])
          self.regions[r].add(i)
  
      edge_num = uniform_int_from_avg(1, avg_deg, self.seed)
  
      t_options = node_options.intersection(self.nodes["T"])
      m_options = node_options.intersection(self.nodes["M"])
      if i in m_options:
          m_options.remove(i)
      d = 0
      while d < edge_num and (len(t_options) > 0 or len(m_options) > 0):
          if len(m_options) == 0 or (
              len(t_options) > 0 and self.seed.random() < t_edge_prob
          ):  # add edge to a T node
              j = self.choose_node_pref_attach(t_options)
              t_options.remove(j)
          else:
              j = self.choose_node_pref_attach(m_options)
              m_options.remove(j)
          self.add_edge(i, j, "transit")
          self.add_customer(i, j)
          d += 1
  
      return i
  
file_path: networkx/networkx/generators/internet_as_graphs.py
imports: import networkx
  from networkx.utils import py_random_state
label_desc: Use image node_id 7 for calling the AS_graph_generator obj's underlying member method code with example usage: obj.add_node(i, kind, reg2prob, avg_deg, t_edge_prob) and returns: i