\GraphDS\AlgoDijkstraMulti

Class defining the multi-path version of Dijkstra's shortest path algorithm.

Summary

Methods
Properties
Constants
__construct()
run()
get()
$graph
$dist
$prev
$unvisitedVertices
$start
$path
$paths
No constants found
No protected methods found
No protected properties found
N/A
enumerate()
No private properties found
N/A

Properties

$dist

$dist : array

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

Type

array

$prev

$prev : array

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

Type

array

$unvisitedVertices

$unvisitedVertices : array

Array holding the unvisited vertices in the graph.

Type

array

$start

$start : mixed

ID of the start vertex.

Type

mixed

$path

$path : array

Array holding a single shortest path.

Type

array

$paths

$paths : array

Array holding the shortest paths in the graph.

Type

array

Methods

__construct()

__construct(\GraphDS\Graph\Graph  $graph) 

Constructor for the multi-path version of Dijkstra algorithm.

Parameters

\GraphDS\Graph\Graph $graph

The graph to which the multi-path Dijkstra algorithm should be applied

run()

run(mixed  $start) : array

Calculates the shortest path to every vertex from vertex $start.

Parameters

mixed $start

ID of the starting vertex for multi-path Dijkstra's algorithm

Throws

\InvalidArgumentException

Returns

array —

Array holding the distances and previous vertices as calculated by Dijkstra's algorithm

get()

get(string  $dest) : array

Returns all shortest paths to $dest from the origin vertex $this->start in the graph.

Parameters

string $dest

ID of the destination vertex

Returns

array —

An array containing the shortest path and distance

enumerate()

enumerate(string  $source, string  $dest) 

Enumerates the result of the multi-path Dijkstra as paths.

Parameters

string $source

ID of the source vertex

string $dest

ID of the destination vertex