This function finds the shortest path from a given 'source' node to all other nodes in the graph using Dijkstra's algorithm. It can be applied to both gGraph and gData objects.
Usage
dijkstraFrom(x, start)
# S4 method for class 'gGraph'
dijkstraFrom(x, start)
# S4 method for class 'gData'
dijkstraFrom(x, start)Value
A gPath object.
Details
The function uses the RBGL package to compute the shortest paths. It checks for the connectivity of the graph and handles cases where there are duplicated paths.
See also
Other dijkstra_methods:
dijkstraBetween(),
dijkstraBuffer(),
gPath2dist()
Examples
# Using a gData object:
# select a few populations from the HGDP dataset
hgdp.sub <- hgdp[getData(hgdp)$Population %in%
c("Orcadian", "Adygei", "Russian", "Basque")]
# select a location of another HGDP population
french.hgdp <- hgdp[getData(hgdp)$Population %in%
c("French")]
# Choose an origin node
french <- getNodes(french.hgdp)
my.path <- dijkstraFrom(hgdp.sub, french)
