\GraphDS\AlgoFloydWarshall

Class defining the Floyd-Warshall algorithm.

Summary

Methods
Properties
Constants
__construct()
run()
get()
$graph
$dist
$next
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$graph

$graph : object

Reference to the graph.

Type

object

$dist

$dist : array

Array holding the shortest distances to each vertex from the source.

Type

array

$next

$next : array

Array holding the next vertices for each vertex for the shortest path.

Type

array

Methods

__construct()

__construct(\GraphDS\Graph\Graph  $graph) 

Constructor for the Floyd-Warshall algorithm.

Parameters

\GraphDS\Graph\Graph $graph

The graph to which the Floyd-Warshall should be applied

Throws

\InvalidArgumentException

run()

run() 

Calculates the shortest paths in the graph using the Floyd-Warshall algorithm.

get()

get(string  $start, string  $dest) : array

Returns the shortest path from vertex $start to $dest in the graph.

Parameters

string $start

ID of the start vertex

string $dest

ID of the destination vertex

Returns

array —

An array containing the shortest path and distance