BellmanFord: The Bellman-Ford algorithm.

Description Usage Arguments Examples

View source: R/BellmanFord.R

Description

This Bellman-Ford implementation solves the Shortest Path Problem (SPP), requiring an adjacency matrix and a source node to be supplied, creating an object of class Bellman-Ford with the solution stored within, this can the be accessed by printing the object or plotting it, for the raw solution data use the class method getPrev(). The Bellman-Ford algorithm discovers negative cycles reachable from the source and reports them.

The graph class has the following class methods:

Usage

1

Arguments

adjMatrix

The ajacency matrix representing the graph to be solved, instead of a matrix the graph class can be supplied, and the adjacency matrix will be extracted.

sourceNode

The source node, corresponds to the node's row in the matrix supplied. Default is 1.

Examples

1
2
3
4
5
6
## Not run: 
  solution <- BellmanFord(matrix,1)
  print(solution)
  plot(solution)
  
## End(Not run)

robert-horne/SPAP documentation built on May 21, 2019, 10:09 a.m.