diff --git a/dace/sdfg/graph.py b/dace/sdfg/graph.py index cc1f051357..7f00971bd0 100644 --- a/dace/sdfg/graph.py +++ b/dace/sdfg/graph.py @@ -364,7 +364,7 @@ def sink_nodes(self) -> List[NodeT]: """Returns nodes with no outgoing edges.""" return [n for n in self.nodes() if self.out_degree(n) == 0] - def bfs_nodes(self, source: NodeT = None) -> Sequence[NodeT]: + def bfs_nodes(self, source: NodeT = None) -> Iterable[NodeT]: """Returns nodes in topological order iff the graph contains exactly one node with no incoming edges.""" if source is not None: @@ -375,17 +375,9 @@ def bfs_nodes(self, source: NodeT = None) -> Sequence[NodeT]: sources = [self.nodes()[0]] if len(sources) > 1: sources = [self.nodes()[0]] - seen = OrderedDict() # No OrderedSet in Python - queue = deque(sources) - while len(queue) > 0: - node = queue.popleft() - seen[node] = None - for e in self.out_edges(node): - succ = e.dst - if succ not in seen: - seen[succ] = None - queue.append(succ) - return seen.keys() + + for edge in self.bfs_edges(sources): + yield edge.src def all_simple_paths(self, source_node: NodeT,