Table of Contents

Class DijkstraMonotonic<TWeight>

Namespace
AlgorithmsSW.EdgeWeightedDigraph
Assembly
AlgorithmsSW.dll

Algorithm to find the shortest path from a source vertex to all other vertices in a edge weighted digraph.

public sealed class DijkstraMonotonic<TWeight> where TWeight : INumber<TWeight>

Type Parameters

TWeight

The type of the edge weights.

Inheritance
DijkstraMonotonic<TWeight>
Inherited Members
Extension Methods

Constructors

DijkstraMonotonic(IReadOnlyEdgeWeightedDigraph<TWeight>, int)

Initializes a new instance of the DijkstraMonotonic<TWeight> class.

public DijkstraMonotonic(IReadOnlyEdgeWeightedDigraph<TWeight> edgeWeightedDigraph, int source)

Parameters

edgeWeightedDigraph IReadOnlyEdgeWeightedDigraph<TWeight>

The edge-weighted directed graph on which the Dijkstra's algorithm will be executed.

source int

The source vertex from which distances to all other vertices in the graph will be calculated.

Methods

DistTo(int)

Gets the shortest path distance from the source vertex to the specified vertex.

public TWeight DistTo(int vertex)

Parameters

vertex int

The vertex to which the shortest path distance should be retrieved.

Returns

TWeight

The shortest path distance from the source vertex to the specified vertex, if the path exists.

Exceptions

InvalidOperationException

The path does not exist.

HasPathTo(int)

Determines whether a path exists from the source vertex to the specified vertex.

public bool HasPathTo(int vertex)

Parameters

vertex int

The vertex to which the presence of a path should be checked.

Returns

bool

true if there is a path from the source vertex to the specified vertex; otherwise, false.

PathTo(int)

Gets the shortest path from the source vertex to the specified vertex.

public IEnumerable<DirectedEdge<TWeight>>? PathTo(int vertex)

Parameters

vertex int

The vertex to which the shortest path should be retrieved.

Returns

IEnumerable<DirectedEdge<TWeight>>

The shortest path from the source vertex to the specified vertex.