dijkstra: Dijkstra's algorithm

Description Usage Arguments Value Author(s) References Examples

View source: R/dijkstra.R

Description

The algorithm takes a graph and an initial node and calculates the shortest path from the initial node to every other node in the graph

Usage

1
dijkstra(graph, init_node)

Arguments

graph

A data frame that contains the edges of the graph and the weight of the edge

init_node

A numeric scalar that exists in the graph

Value

The shortest distance from init_node to every other node

Author(s)

Simon and Mohamed

References

https://en.wikipedia.org/wiki/Dijkstras_algorithm/

Examples

1
2
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)), 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)), 3)

Elmahi92/smplab documentation built on Dec. 17, 2021, 6:28 p.m.