class_docstr: Generates random internet AS graphs.
class_docstr_tok: ["Generates","random","internet","AS","graphs","."]
docstr: Add a peering link to a content provider (CP) node.
  
  Target node j can be CP or M and it is drawn uniformly among the nodes
  belonging to the same region as cp.
  
  Parameters
  ----------
  cp: object
      Node identifier
  to_kind: string
      type for target node j (must be M or CP)
  
  Returns
  -------
  success: boolean
docstr_tok: ["Add","a","peering","link","to","a","content","provider","(","CP",")","node",".","Target","node","j","can","be","CP","or","M","and","it","is","drawn","uniformly","among","the","nodes","belonging","to","the","same","region","as","cp",".","Parameters","--","--","--","--","--","cp",":","object","Node","identifier","to_kind",":","string","type","for","target","node","j","(","must","be","M","or","CP",")","Returns","--","--","--","-","success",":","boolean"]
code: def add_cp_peering_link(self, cp, to_kind):
      """Add a peering link to a content provider (CP) node.
  
      Target node j can be CP or M and it is drawn uniformly among the nodes
      belonging to the same region as cp.
  
      Parameters
      ----------
      cp: object
          Node identifier
      to_kind: string
          type for target node j (must be M or CP)
  
      Returns
      -------
      success: boolean
      """
  
      node_options = set()
      for (
          r
      ) in self.regions:  # options include nodes in the same region(s)
          if cp in self.regions[r]:
              node_options = node_options.union(self.regions[r])
  
      # options are restricted to the indicated kind ('M' or 'CP')
      node_options = self.nodes[to_kind].intersection(node_options)
  
      # remove self
      if cp in node_options:
          node_options.remove(cp)
  
      # remove nodes that are cp's providers
      node_options = node_options.difference(self.providers[cp])
  
      # remove nodes we are already connected to
      for j in self.G.neighbors(cp):
          if j in node_options:
              node_options.remove(j)
  
      if len(node_options) > 0:
          j = self.seed.sample(list(node_options), 1)[0]
          self.add_edge(cp, j, "peer")
          self.G.nodes[cp]["peers"] += 1
          self.G.nodes[j]["peers"] += 1
          return True
      else:
          return False
  
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 9 for calling the AS_graph_generator obj's underlying member method code with example usage: obj.add_cp_peering_link(cp, to_kind) and returns: True, False