mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-12 22:37:21 +02:00
[core] Graph: raise error in dfs() with longestPathFirst
This commit is contained in:
parent
5f444e6810
commit
eb52459bbf
1 changed files with 9 additions and 2 deletions
|
@ -653,6 +653,11 @@ class Graph(BaseObject):
|
|||
for u in self._nodes:
|
||||
colors[u] = WHITE
|
||||
|
||||
if longestPathFirst and reverse:
|
||||
# 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
|
||||
raise NotImplementedError("Graph.dfs(): longestPathFirst=True and reverse=True are not compatible yet.")
|
||||
|
||||
nodes = startNodes or self.getLeaves()
|
||||
|
||||
if longestPathFirst:
|
||||
|
@ -873,7 +878,7 @@ class Graph(BaseObject):
|
|||
flowEdges.append(link)
|
||||
return flowEdges
|
||||
|
||||
def nodesFromNode(self, startNode, filterTypes=None, reverse=True):
|
||||
def nodesFromNode(self, startNode, filterTypes=None, longestPathFirst=False, reverse=True):
|
||||
"""
|
||||
Return the node chain from startNode to the graph leaves.
|
||||
|
||||
|
@ -881,6 +886,8 @@ class Graph(BaseObject):
|
|||
startNode (Node): the node to start the visit from.
|
||||
filterTypes (str list): (optional) only return the nodes of the given types
|
||||
(does not stop the visit, this is a post-process only)
|
||||
longestPathFirst (bool): (optional) if multiple paths, nodes belonging to
|
||||
the longest one will be visited first.
|
||||
reverse (bool): (optional) direction of visit.
|
||||
True is for getting nodes depending on the startNode.
|
||||
False is for getting nodes required for the startNode.
|
||||
|
@ -897,7 +904,7 @@ class Graph(BaseObject):
|
|||
|
||||
visitor.discoverVertex = discoverVertex
|
||||
visitor.examineEdge = lambda edge, graph: edges.append(edge)
|
||||
self.dfs(visitor=visitor, startNodes=[startNode], reverse=reverse)
|
||||
self.dfs(visitor=visitor, startNodes=[startNode], longestPathFirst=longestPathFirst, reverse=reverse)
|
||||
return nodes, edges
|
||||
|
||||
def getInputNodes(self, node, recursive=False):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue