From 923b523e848c72d51d6f96a3c21c131abd2a33f0 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Wed, 12 Jul 2023 11:57:04 +0200 Subject: [PATCH] Let AnnotatedTopology have a VertexFinder attached Annotators may want to match vertices based on partial information. Especially, with split visualisation.ospf, we want to be able to match for networks even without the full details (like DRs or all the current prefixes.) This finally uses the VertexFinder :-) Also, it is definitely not a dataclass, who wrote that? ;-) --- birdvisu/annotations/__init__.py | 4 +++- birdvisu/topo_v3.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/birdvisu/annotations/__init__.py b/birdvisu/annotations/__init__.py index bef0c90..667572c 100644 --- a/birdvisu/annotations/__init__.py +++ b/birdvisu/annotations/__init__.py @@ -22,7 +22,7 @@ indirections to iterating over all annotation of a particular vertex/edge. We believe that the latter is less common operation, so this seems like a good approach.""" -from ..topo_v3 import TopologyV3, VertexID, Edge +from ..topo_v3 import TopologyV3, VertexID, Edge, VertexFinder from collections import defaultdict from collections.abc import Hashable from dataclasses import dataclass, field @@ -33,6 +33,8 @@ class AnnotatedTopology: def __init__(self, topology): if not topology.frozen: raise ValueError('Can only annotate frozen topologies.') self.topology = topology + self.finder = VertexFinder() + self.finder.add_topology(topology) self.annotations: dict['AnnotatorID', 'Annotation'] = dict() # Keeping track of dependencies self.running_annotations = set() diff --git a/birdvisu/topo_v3.py b/birdvisu/topo_v3.py index f11e59f..b25ccc4 100644 --- a/birdvisu/topo_v3.py +++ b/birdvisu/topo_v3.py @@ -235,7 +235,6 @@ class Edge: # adding them to a topology. virtual: bool = False -@dataclass class VertexFinder: """Tracker of presence of vertices in topologies.