dijkstra: The Dijkstra Algorithm

Description Usage Arguments Value See Also Examples

View source: R/dijkstra.R

Description

Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a graph.

Usage

1
dijkstra(graph, init_node)

Arguments

graph

A Data Frame

init_node

A Numerical Scalar

Value

Return the shortest path to every other node from the starting node as a vector.

See Also

More informartion can be found in https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

Examples

1
2
3
4
5
wiki_graph <- data.frame(v1=c(1,1,1,2,2,2,3,3,3,3,4,4,4,5,5,6,6,6),
v2=c(2,3,6,1,3,4,1,2,4,6,2,3,5,4,6,1,3,5),
w=c(7,9,14,7,10,15,9,10,11,2,15,11,6,6,9,14,2,9))
dijkstra(wiki_graph, 1)
dijkstra(wiki_graph, 3)

abkw/lab03 documentation built on Oct. 31, 2019, 1:55 a.m.