-
Notifications
You must be signed in to change notification settings - Fork 9
Subclassing edges and vertices
Peter Corke edited this page Jun 27, 2021
·
1 revision
For particular applications it is convenient to subclass Edge or Vertex. When subclassing vertices it is important to subclass
UVertex if the graph is undirected and DVertex if the graph is directed.
For example:
class PGVertex(pgraph.UVertex):
nvertices = 0 # count of PGVertex instances
def __init__(self, type, **kwargs):
super().__init__(**kwargs) # superclass initialiser
self.type = type # pose graph vertex type
self.index = PGVertex.nvertices # pose graph vertex id
PGVertex.nvertices += 1
class PGEdge(pgraph.Edge):
def __init__(self, v1, v2, mean, info):
super().__init__(v1, v2) # superclass initialiser
self.mean = mean # edge cost
self.info = info # edge information matrix
## methods on edges
def linear_factors(self):
#computes the Taylor expansion of the error function of the k_th edge
...