def add_node(self, node):
        """Add a node, connecting it to all the active nodes."""
        nodes = sorted(
            self.nodes(),
            key=attrgetter('creation_time'), reverse=True)

        other_nodes = [n for n in nodes if n.id != node.id]

        connecting_nodes = other_nodes[0:(self.n - 1)]

        for n in connecting_nodes:
            n.connect(whom=node)
def add_node ( self , node ) : nodes = sorted ( self . nodes ( ) , key = attrgetter ( 'creation_time' ) , reverse = True ) other_nodes = [ n for n in nodes if n . id != node . id ] connecting_nodes = other_nodes [ 0 : ( self . n - 1 ) ] for n in connecting_nodes : n . connect ( whom = node )
Add a node, connecting it to all the active nodes.