fixed get_all_dag_edges prevent it emitting edges multiple time

This commit is contained in:
Nicolas Kruse 2025-12-03 17:27:29 +01:00
parent cc5582ae73
commit a30ee12d0f
1 changed files with 7 additions and 1 deletions

View File

@ -64,9 +64,15 @@ def get_all_dag_edges(nodes: Iterable[Node]) -> Generator[tuple[Node, Node], Non
Yields: Yields:
Tuples of (source_node, target_node) representing edges in the DAG Tuples of (source_node, target_node) representing edges in the DAG
""" """
emitted_nodes: set[tuple[Node, Node]] = set()
for node in nodes: for node in nodes:
yield from get_all_dag_edges(net.source for net in node.args) yield from get_all_dag_edges(net.source for net in node.args)
yield from ((net.source, node) for net in node.args) for net in node.args:
edge = (net.source, node)
if edge not in emitted_nodes:
yield edge
emitted_nodes.add(edge)
def get_const_nets(nodes: list[Node]) -> list[Net]: def get_const_nets(nodes: list[Node]) -> list[Net]: