def add_node(self, node):
num_agents = len(self.nodes(type=Agent))<EOL>curr_generation = int((num_agents - <NUM_LIT:1>) / float(self.generation_size))<EOL>node.generation = curr_generation<EOL>if curr_generation == <NUM_LIT:0> and self.initial_source:<EOL><INDENT>parent = self._select_oldest_source()<EOL><DEDENT>else:<EOL><INDENT>parent = self._select_fit_node_from_generation(<EOL>node_type=type(node), generation=curr_generation - <NUM_LIT:1><EOL>)<EOL><DEDENT>if parent is not None:<EOL><INDENT>parent.connect(whom=node)<EOL>parent.transmit(to_whom=node)<EOL><DEDENT>
Link to the agent from a parent based on the parent's fitness