Skip to content

Commit da833c2

Browse files
committed
method to find distance to point
1 parent 093bc3a commit da833c2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pgraph/PGraph.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,21 @@ def edges(self):
14101410
def heuristic_distance(self, v2):
14111411
return self._graph.heuristic(self.coord - v2.coord)
14121412

1413+
def distance(self, coord):
1414+
"""
1415+
Distance from vertex to point
1416+
1417+
:param coord: coordinates of the point
1418+
:type coord: ndarray(n)
1419+
:return: distance
1420+
:rtype: float
1421+
1422+
Distance is computed according to the graph's metric.
1423+
1424+
:seealso: :meth:`metric`
1425+
"""
1426+
return self._graph.metric(self.coord - coord)
1427+
14131428
@property
14141429
def degree(self):
14151430
"""

0 commit comments

Comments
 (0)