mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-01 15:58:36 +02:00
[core] Graph: fix reverse issue in dfs()
This commit is contained in:
parent
8499431dff
commit
deaf1e3abb
1 changed files with 4 additions and 4 deletions
|
@ -652,8 +652,8 @@ class Graph(BaseObject):
|
||||||
return nodeEdges
|
return nodeEdges
|
||||||
|
|
||||||
def dfs(self, visitor, startNodes=None, longestPathFirst=False):
|
def dfs(self, visitor, startNodes=None, longestPathFirst=False):
|
||||||
# Default direction: from node to root
|
# Default direction (visitor.reverse=False): from node to root
|
||||||
# Reverse direction: from node to leaves
|
# Reverse direction (visitor.reverse=True): from node to leaves
|
||||||
nodeChildren = self._getOutputEdgesPerNode() if visitor.reverse else self._getInputEdgesPerNode()
|
nodeChildren = self._getOutputEdgesPerNode() if visitor.reverse else self._getInputEdgesPerNode()
|
||||||
# Initialize color map
|
# Initialize color map
|
||||||
colors = {}
|
colors = {}
|
||||||
|
@ -663,9 +663,9 @@ class Graph(BaseObject):
|
||||||
if longestPathFirst and visitor.reverse:
|
if longestPathFirst and visitor.reverse:
|
||||||
# Because we have no knowledge of the node's count between a node and its leaves,
|
# Because we have no knowledge of the node's count between a node and its leaves,
|
||||||
# it is not possible to handle this case at the moment
|
# it is not possible to handle this case at the moment
|
||||||
raise NotImplementedError("Graph.dfs(): longestPathFirst=True and reverse=True are not compatible yet.")
|
raise NotImplementedError("Graph.dfs(): longestPathFirst=True and visitor.reverse=True are not compatible yet.")
|
||||||
|
|
||||||
nodes = startNodes or self.getLeafNodes()
|
nodes = startNodes or (self.getRootNodes() if visitor.reverse else self.getLeafNodes())
|
||||||
|
|
||||||
if longestPathFirst:
|
if longestPathFirst:
|
||||||
# Graph topology must be known and node depths up-to-date
|
# Graph topology must be known and node depths up-to-date
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue