Learn R Programming

spatgraphs (version 2.62)

spatgraphs-shortestPath: Shortest path between nodes i and j

Description

Find the shortest edgeconnected path between two given nodes/points with indices i and j (in pp).

Usage

shortestPath(i, j, g, pp=NULL, dbg=FALSE)

Arguments

i
The start node of the path to find.
j
The target node of the path to find.
g
Graph which defines the edges.
pp
Point pattern. If given, the edges are of Euclidian length, otherwise each edge is of length 1.
dbg
Print runtime messages.

Details

ll{ Date: 2008-09-25 License: GPL v2 or later } Returns the distance and edges along the shortest path. Make sure the graph is symmetric. The algorithm is Dijkstra's algorithm.

References

E. W. Dijkstra: A note on two problems in connexion with graphs. 'Numerische Mathematik', 1 (1959), p. 269-271.

http://en.wikipedia.org/wiki/Dijkstra's_algorithm