Adds a node to the graph. Args: node (BaseNode): The node instance to add to the graph.
(self, node)
| 376 | return state, exec_info |
| 377 | |
| 378 | def append_node(self, node): |
| 379 | """ |
| 380 | Adds a node to the graph. |
| 381 | |
| 382 | Args: |
| 383 | node (BaseNode): The node instance to add to the graph. |
| 384 | """ |
| 385 | |
| 386 | # if node name already exists in the graph, raise an exception |
| 387 | if node.node_name in {n.node_name for n in self.nodes}: |
| 388 | raise ValueError( |
| 389 | f"""Node with name '{node.node_name}' already exists in the graph. |
| 390 | You can change it by setting the 'node_name' attribute.""" |
| 391 | ) |
| 392 | |
| 393 | last_node = self.nodes[-1] |
| 394 | self.raw_edges.append((last_node, node)) |
| 395 | self.nodes.append(node) |
| 396 | self.edges = self._create_edges(set(self.raw_edges)) |