class Dijkstra implements AlgorithmInterface (View source)

## Properties

 protected \$startingVertex protected \$endingVertex protected \$graph protected \$paths protected \$solution

## Methods

__construct(GraphInterface \$graph)

Instantiates a new algorithm, requiring a graph to work with.

integer
getDistance()

Returns the distance between the starting and the ending point.

getEndingVertex()

Gets the vertex which we are pointing to.

string
getLiteralShortestPath()

Returns the solution in a human-readable style.

Array
getShortestPath()

Reverse-calculates the shortest path of the graph thanks the potentials stored in the vertices.

getStartingVertex()

Retrieves the vertex which we are starting from to calculate the shortest path.

setEndingVertex(VertexInterface \$vertex)

Sets the vertex which we are pointing to.

setStartingVertex(VertexInterface \$vertex)

Sets the vertex which we are starting from to calculate the shortest path.

mixed
solve()

Solves the algorithm and returns all possible results.

calculatePotentials(VertexInterface \$vertex)

Recursively calculates the potentials of the graph, from the starting point you specify with ->setStartingVertex(), traversing the graph due to Vertex's \$connections attribute.

getGraph()

Returns the graph associated with this algorithm instance.

Array
getPaths()

Returns the possible paths registered in the graph.

boolean
isSolved()

Checks wheter the current algorithm has been solved or not.

## Details

### at line 41``` __construct(GraphInterface \$graph) ```

Instantiates a new algorithm, requiring a graph to work with.

#### Parameters

 GraphInterface \$graph

### at line 51``` integer getDistance() ```

Returns the distance between the starting and the ending point.

#### Return Value

 integer

### at line 67``` VertexInterface getEndingVertex() ```

Gets the vertex which we are pointing to.

### at line 77``` string getLiteralShortestPath() ```

Returns the solution in a human-readable style.

 string

### at line 95``` Array getShortestPath() ```

Reverse-calculates the shortest path of the graph thanks the potentials stored in the vertices.

 Array

### at line 115``` VertexInterface getStartingVertex() ```

Retrieves the vertex which we are starting from to calculate the shortest path.

### at line 125``` setEndingVertex(VertexInterface \$vertex) ```

Sets the vertex which we are pointing to.

#### Parameters

 VertexInterface \$vertex

### at line 135``` setStartingVertex(VertexInterface \$vertex) ```

Sets the vertex which we are starting from to calculate the shortest path.

#### Parameters

 VertexInterface \$vertex

### at line 144``` mixed solve() ```

Solves the algorithm and returns all possible results.

 mixed

### at line 163``` protected calculatePotentials(VertexInterface \$vertex) ```

Recursively calculates the potentials of the graph, from the starting point you specify with ->setStartingVertex(), traversing the graph due to Vertex's \$connections attribute.

#### Parameters

 VertexInterface \$vertex

### at line 201``` protected GraphInterface getGraph() ```

Returns the graph associated with this algorithm instance.

### at line 211``` protected Array getPaths() ```

Returns the possible paths registered in the graph.

 Array

### at line 221``` protected boolean isSolved() ```

Checks wheter the current algorithm has been solved or not.

#### Return Value

 boolean