dijkstra: Dijkstra

Description Usage Arguments Value Examples

View source: R/dijkstra.R

Description

Find the shortest distance from init_node to all nodes in graph.

Usage

1
dijkstra(graph, init_node)

Arguments

graph,

a graph table with all neighbors and the distance to them.

init_node,

a starting point of numeric numbers.

Value

The shortest distance from init_node to all nodes in graph.

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)  

yewei369/FancyPack.R.LiU.3 documentation built on Nov. 5, 2019, 12:34 p.m.