[ui/core] Order last node of type according to node's depth and name

This commit is contained in:
Aurore LAFAURIE 2024-05-17 10:27:32 +02:00
parent 4e8c0c2cf8
commit 663b6b66d4
2 changed files with 3 additions and 5 deletions

View file

@ -929,10 +929,6 @@ class Graph(BaseObject):
for edge in self.getEdges(dependenciesOnly=dependenciesOnly):
nodeEdges[edge.src.node].add(edge.dst.node)
# sort the edges
for node in nodeEdges:
nodeEdges[node] = sorted(nodeEdges[node], key=lambda item: item.name)
return nodeEdges
@ -1114,7 +1110,7 @@ class Graph(BaseObject):
self._computationBlocked.clear()
compatNodes = []
visitor = Visitor(reverse=False, dependenciesOnly=True)
visitor = Visitor(reverse=False, dependenciesOnly=False)
def discoverVertex(vertex, graph):
# initialize depths

View file

@ -665,6 +665,8 @@ class Reconstruction(UIGraph):
nodes = self._graph.dfsOnDiscover(startNodes=[startNode], filterTypes=nodeTypes, reverse=True)[0]
if not nodes:
return None
# order the nodes according to their depth in the graph, then according to their name
nodes.sort(key=lambda n: (n.depth, n.name))
node = nodes[-1]
if preferredStatus:
node = next((n for n in reversed(nodes) if n.getGlobalStatus() == preferredStatus), node)