dijkstra: Dijkstra's algorithm - Find the shortest path of the given...

Description Usage Arguments Value References Examples

View source: R/Lab3_group11.R

Description

Dijkstra's algorithm - Find the shortest path of the given graph.

Usage

1
dijkstra(df, init_nod)

Arguments

df

A data frame (the graph).

init_nod

A numbe (the start node).

Value

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

References

https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

Examples

1
2
3
4
5
6
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)

kelly-ly/LAB-3 documentation built on Nov. 4, 2019, 3:46 p.m.