def add_node(self, node):
other_nodes = [n for n in self.nodes() if n.id != node.id]<EOL>if isinstance(node, Source) and other_nodes:<EOL><INDENT>raise Exception("<STR_LIT>" "<STR_LIT>")<EOL><DEDENT>if other_nodes:<EOL><INDENT>parent = max(other_nodes, key=attrgetter("<STR_LIT>"))<EOL>parent.connect(whom=node)<EOL><DEDENT>
Add an agent, connecting it to the previous node.