Table of Contents

Interface IShortestPathAlgorithm<TVertex, TEdge, TWeight>

Namespace
Graph1x.Algorithms
Assembly
Graph1x.dll

A single-pair shortest-path strategy. Implementations (Dijkstra, Bellman-Ford, A*) are interchangeable behind this interface; pick by the graph's weight profile (non-negative, negative edges, heuristic available).

public interface IShortestPathAlgorithm<TVertex, TEdge, TWeight> where TVertex : notnull where TEdge : IEdge<TVertex> where TWeight : INumber<TWeight>

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

TWeight

The numeric weight type.

Methods

FindPath(IReadOnlyGraph<TVertex, TEdge>, TVertex, TVertex)

Finds the shortest path from source to target.

ShortestPathResult<TVertex, TWeight> FindPath(IReadOnlyGraph<TVertex, TEdge> graph, TVertex source, TVertex target)

Parameters

graph IReadOnlyGraph<TVertex, TEdge>

The graph to search.

source TVertex

The start vertex.

target TVertex

The end vertex.

Returns

ShortestPathResult<TVertex, TWeight>

The query result, unreachable when no path exists.

Exceptions

ArgumentException

Either endpoint is not in the graph.