mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-13 23:07:21 +02:00
[core] Graph: change signature of dfsOnFinish()
This commit is contained in:
parent
b567d8ff5c
commit
e4a95e89dc
1 changed files with 15 additions and 4 deletions
|
@ -701,22 +701,33 @@ class Graph(BaseObject):
|
||||||
colors[u] = BLACK
|
colors[u] = BLACK
|
||||||
visitor.finishVertex(u, self)
|
visitor.finishVertex(u, self)
|
||||||
|
|
||||||
def dfsOnFinish(self, startNodes=None):
|
def dfsOnFinish(self, startNodes=None, longestPathFirst=False, reverse=False):
|
||||||
"""
|
"""
|
||||||
:param startNodes: list of starting nodes. Use all leaves if empty.
|
Return the node chain from startNodes to the graph roots/leaves.
|
||||||
:return: visited nodes and edges. The order is defined by the visit and finishVertex event.
|
Order is defined by the visit and finishVertex event.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
startNodes (Node list): the nodes to start the visit from.
|
||||||
|
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 startNodes (to leaves).
|
||||||
|
False is for getting nodes required for the startNodes (to roots).
|
||||||
|
Returns:
|
||||||
|
The list of nodes and edges, from startNodes to the graph roots/leaves following edges.
|
||||||
"""
|
"""
|
||||||
nodes = []
|
nodes = []
|
||||||
edges = []
|
edges = []
|
||||||
visitor = Visitor()
|
visitor = Visitor()
|
||||||
visitor.finishVertex = lambda vertex, graph: nodes.append(vertex)
|
visitor.finishVertex = lambda vertex, graph: nodes.append(vertex)
|
||||||
visitor.finishEdge = lambda edge, graph: edges.append(edge)
|
visitor.finishEdge = lambda edge, graph: edges.append(edge)
|
||||||
self.dfs(visitor=visitor, startNodes=startNodes)
|
self.dfs(visitor=visitor, startNodes=startNodes, longestPathFirst=longestPathFirst, reverse=reverse)
|
||||||
return nodes, edges
|
return nodes, edges
|
||||||
|
|
||||||
def dfsOnDiscover(self, startNodes, filterTypes=None, longestPathFirst=False, reverse=False):
|
def dfsOnDiscover(self, startNodes, filterTypes=None, longestPathFirst=False, reverse=False):
|
||||||
"""
|
"""
|
||||||
Return the node chain from startNodes to the graph roots/leaves.
|
Return the node chain from startNodes to the graph roots/leaves.
|
||||||
|
Order is defined by the visit and discoverVertex event.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
startNodes (Node list): the nodes to start the visit from.
|
startNodes (Node list): the nodes to start the visit from.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue