|
|
@ -8,6 +8,7 @@ from ..topo_v3 import MetricType
|
|
|
|
import heapq
|
|
|
|
import heapq
|
|
|
|
from enum import Enum
|
|
|
|
from enum import Enum
|
|
|
|
from functools import total_ordering
|
|
|
|
from functools import total_ordering
|
|
|
|
|
|
|
|
from collections import defaultdict
|
|
|
|
|
|
|
|
|
|
|
|
class TopologyDifference(Annotator):
|
|
|
|
class TopologyDifference(Annotator):
|
|
|
|
"""Finds differences between ancestors.
|
|
|
|
"""Finds differences between ancestors.
|
|
|
@ -51,16 +52,19 @@ class TopologyDifference(Annotator):
|
|
|
|
newe = new.edges
|
|
|
|
newe = new.edges
|
|
|
|
only_old = olde - newe
|
|
|
|
only_old = olde - newe
|
|
|
|
only_new = newe - olde
|
|
|
|
only_new = newe - olde
|
|
|
|
common = olde & newe
|
|
|
|
# Note: edge can not be discrepant, since it is determined by all its
|
|
|
|
discrepant = set()
|
|
|
|
# details. However, it is useful to highlight edges with changed cost.
|
|
|
|
for edge in common:
|
|
|
|
changed_cost_old: dict[tuple[VertexID, VertexID], list[Edge]] = defaultdict(lambda: [])
|
|
|
|
o = old.edges[edge]
|
|
|
|
for e in only_old: changed_cost_old[(e.source, e.target)].append(e)
|
|
|
|
n = new.edges[edge]
|
|
|
|
changed_cost_new: dict[tuple[VertexID, VertexID], list[Edge]] = defaultdict(lambda: [])
|
|
|
|
if o != n: discrepant.add(edge)
|
|
|
|
for e in only_new: changed_cost_new[(e.source, e.target)].append(e)
|
|
|
|
|
|
|
|
|
|
|
|
for e in only_old: result.for_edge[e] = self.Status.Missing
|
|
|
|
for e in only_old: result.for_edge[e] = self.Status.Missing
|
|
|
|
for e in only_new: result.for_edge[e] = self.Status.New
|
|
|
|
for e in only_new: result.for_edge[e] = self.Status.New
|
|
|
|
for e in discrepant: result.for_edge[e] = self.Status.Discrepant
|
|
|
|
for k in changed_cost_old.keys() & changed_cost_new.keys():
|
|
|
|
|
|
|
|
# We override the New/Missing status in this case.
|
|
|
|
|
|
|
|
for e in changed_cost_old[k]: result.for_edge[e] = self.Status.Discrepant
|
|
|
|
|
|
|
|
for e in changed_cost_new[k]: result.for_edge[e] = self.Status.Discrepant
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
class ShortestPathTree(Annotator):
|
|
|
|
class ShortestPathTree(Annotator):
|
|
|
|