Landmark.closest#

Landmark.closest() → tuple[Vertex | None, float]#

Return the closest vertex to this vertex

Returns:

closest vertex and its distance

Return type:

Vertex subclass or None, float

Equivalent to self._graph.closest(self.coord). The vertex must belong to a graph, since closest() searches that graph’s other vertices.

>>> from pgraph import UGraph
>>> g = UGraph()
>>> v1 = g.add_vertex(coord=[0,0], name='v1')
>>> v2 = g.add_vertex(coord=[1,1], name='v2')
>>> v3 = g.add_vertex(coord=[2,3], name='v3')
>>> v4 = g.add_vertex(coord=[4,3], name='v4')
>>> print(v1.closest())
(Vertex[v1, coord=(0, 0)], 0.0)
Seealso:

Graph.closest