dijkstra: Find shortest distance in a graph

Description Usage Arguments Value References Examples

Description

Find shortest distance in a graph

Usage

1
dijkstra(graph, init_node)

Arguments

graph

The Graph. Should be data.frame with 3 numerical columns. The first column contains the starting vertices of each edges, when the second one contains the ending vertices of these edges. The third columns contains the weights of each edge.

init_node

The vertix fro?m which the distances are calculated

Value

A vector with the distance between init_node all the other vertices.

References

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

Examples

1
dijkstra(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)), init_node=1)

brbatv/lab3 documentation built on May 9, 2019, 6:03 p.m.