[core] graph: re-implement getDepth to return the correct value

This commit is contained in:
Fabien Castan 2017-10-16 11:00:36 +02:00
parent 2024d7ab1c
commit 3ca3a794fe

View file

@ -623,7 +623,12 @@ class Graph(BaseObject):
self.addEdge(*edge) self.addEdge(*edge)
def getDepth(self, node): def getDepth(self, node):
return len(self.dfsNodesOnFinish([node])) # TODO: would be better to use bfs instead of recursive function
inputEdges = self.getInputEdges(node)
if not inputEdges:
return 0
inputDepths = [e.src.node.depth for e in inputEdges]
return min(inputDepths) + 1
def _getNodeEdges(self): def _getNodeEdges(self):
nodeEdges = defaultdict(set) nodeEdges = defaultdict(set)