dijkstra: Dijkstra Algorithm

Description Usage Arguments Details Examples

Description

Use Dijkstra's algorithm to solve a shortest path problem.

Usage

1
dijkstra(graph, from, to)

Arguments

graph

The graph object.

from

The source vertex

to

The target vertex

Details

Dijkstra is a single-source algorithm which cannot deal with negative edge weights. Technically, it is a special case of A*-Search (aStarSearch) where the heuristic function is zero.

Examples

1
2
3
4
5
6
7
8
g <- randomGraph(6)
d <- dijkstra(g, "A", "F")

plot(d)

for(step in d){
  print(step$min_dists)
}

mhils/shortestpath documentation built on Dec. 17, 2020, 3:19 p.m.