code: def add_node(self, node):
          nodes = self.nodes()
          if len(nodes) <= self.m0:
              other_nodes = [n for n in nodes if n.id != node.id]
              for n in other_nodes:
                  node.connect(direction="both", whom=n)
          else:
              for idx_newvector in xrange(self.m):
                  these_nodes = [
                      n for n in nodes if (
                          n.id != node.id and
                          not n.is_connected(direction="either", whom=node))]
                  outdegrees = [
                      len(n.vectors(direction="outgoing")) for n in these_nodes]
                  ps = [(d / (1.0 * sum(outdegrees))) for d in outdegrees]
                  rnd = random.random() * sum(ps)
                  cur = 0.0
                  for i, p in enumerate(ps):
                      cur += p
                      if rnd < cur:
                          vector_to = these_nodes[i]
                  node.connect(direction="both", whom=vector_to)