mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(nodes): use DFS with preorder traversal
This commit is contained in:
parent
9c57b18008
commit
c91b071c47
@ -1131,13 +1131,13 @@ class GraphExecutionState(BaseModel):
|
|||||||
"""Gets the deepest node that is ready to be executed"""
|
"""Gets the deepest node that is ready to be executed"""
|
||||||
g = self.execution_graph.nx_graph()
|
g = self.execution_graph.nx_graph()
|
||||||
|
|
||||||
# we need to traverse the graph in from bottom up
|
# Depth-first search with pre-order traversal is a depth-first topological sort
|
||||||
reversed_sorted_nodes = reversed(list(nx.topological_sort(g)))
|
sorted_nodes = nx.dfs_preorder_nodes(g)
|
||||||
|
|
||||||
next_node = next(
|
next_node = next(
|
||||||
(
|
(
|
||||||
n
|
n
|
||||||
for n in reversed_sorted_nodes
|
for n in sorted_nodes
|
||||||
if n not in self.executed # the node must not already be executed...
|
if n not in self.executed # the node must not already be executed...
|
||||||
and all((e[0] in self.executed for e in g.in_edges(n))) # ...and all its inputs must be executed
|
and all((e[0] in self.executed for e in g.in_edges(n))) # ...and all its inputs must be executed
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user