Table of Contents

Class DijkstraAllPairs<TWeight>

Namespace
AlgorithmsSW.EdgeWeightedDigraph
Assembly
AlgorithmsSW.dll

A class for finding the shortest path from a source vertex to all other vertices in a directed edge weighted graph.

public class DijkstraAllPairs<TWeight> where TWeight : INumber<TWeight>, IMinMaxValue<TWeight>

Type Parameters

TWeight

The type of the edge weights.

Inheritance
DijkstraAllPairs<TWeight>
Inherited Members
Extension Methods

Constructors

DijkstraAllPairs(IReadOnlyEdgeWeightedDigraph<TWeight>)

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

public DijkstraAllPairs(IReadOnlyEdgeWeightedDigraph<TWeight> graph)

Parameters

graph IReadOnlyEdgeWeightedDigraph<TWeight>

The graph to find the shortest paths in.

Methods

GetDistance(int, int)

Gets the distance from the source vertex to the target vertex.

public TWeight GetDistance(int sourceVertex, int targetVertex)

Parameters

sourceVertex int

The vertex to find the distance from.

targetVertex int

The vertex to find the distance to.

Returns

TWeight

The distance from the source vertex to the target vertex.

GetPath(int, int)

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

public IEnumerable<DirectedEdge<TWeight>> GetPath(int sourceVertex, int targetVertex)

Parameters

sourceVertex int

The vertex to find the shortest path from.

targetVertex int

The vertex to find the shortest path to.

Returns

IEnumerable<DirectedEdge<TWeight>>

An enumerable of edges representing the shortest path.