Table of Contents

Class SingleSourceShortestPaths<TVertex, TWeight>

Namespace
Graph1x.Algorithms
Assembly
Graph1x.dll

The result of a single-source shortest-path computation: distances and a predecessor tree from one source to every reachable vertex, queryable per target without re-running the algorithm. The result is a snapshot of the graph at computation time.

public sealed class SingleSourceShortestPaths<TVertex, TWeight> where TVertex : notnull where TWeight : INumber<TWeight>

Type Parameters

TVertex

The vertex type.

TWeight

The numeric weight type.

Inheritance
SingleSourceShortestPaths<TVertex, TWeight>
Inherited Members

Properties

Distances

Gets the shortest distance to every reachable vertex (unreachable vertices are absent; the source maps to zero).

public IReadOnlyDictionary<TVertex, TWeight> Distances { get; }

Property Value

IReadOnlyDictionary<TVertex, TWeight>

Source

Gets the vertex the computation started from.

public TVertex Source { get; }

Property Value

TVertex

Methods

IsReachable(TVertex)

Determines whether target is reachable from the source.

public bool IsReachable(TVertex target)

Parameters

target TVertex

The vertex to test.

Returns

bool

true if a path exists.

Exceptions

ArgumentException

target was not part of the analyzed graph.

To(TVertex)

Gets the shortest path from the source to target.

public ShortestPathResult<TVertex, TWeight> To(TVertex target)

Parameters

target TVertex

The end vertex.

Returns

ShortestPathResult<TVertex, TWeight>

The query result, unreachable when no path exists.

Exceptions

ArgumentException

target was not part of the analyzed graph.