Table of Contents

Class ShortestPathResult<TVertex, TWeight>

Namespace
Graph1x.Algorithms
Assembly
Graph1x.dll

The outcome of a shortest-path query: whether the target is reachable, the total distance, and the vertex path from source to target.

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

Type Parameters

TVertex

The vertex type.

TWeight

The numeric weight type.

Inheritance
ShortestPathResult<TVertex, TWeight>
Inherited Members

Constructors

ShortestPathResult(TVertex, TVertex)

Initializes an unreachable result.

public ShortestPathResult(TVertex source, TVertex target)

Parameters

source TVertex

The path's start vertex.

target TVertex

The unreachable end vertex.

Exceptions

ArgumentNullException

Any argument is null.

ShortestPathResult(TVertex, TVertex, TWeight, IReadOnlyList<TVertex>)

Initializes a reachable result.

public ShortestPathResult(TVertex source, TVertex target, TWeight distance, IReadOnlyList<TVertex> path)

Parameters

source TVertex

The path's start vertex.

target TVertex

The path's end vertex.

distance TWeight

The total path weight.

path IReadOnlyList<TVertex>

The vertices from source to target inclusive.

Exceptions

ArgumentNullException

Any argument is null.

Properties

Distance

Gets the total weight of the shortest path.

public TWeight Distance { get; }

Property Value

TWeight

Exceptions

InvalidOperationException

The target is not reachable.

IsReachable

Gets a value indicating whether a path exists.

public bool IsReachable { get; }

Property Value

bool

Path

Gets the vertices of the shortest path from Source to Target inclusive, or an empty list when unreachable.

public IReadOnlyList<TVertex> Path { get; }

Property Value

IReadOnlyList<TVertex>

Source

Gets the vertex the query started from.

public TVertex Source { get; }

Property Value

TVertex

Target

Gets the vertex the query aimed for.

public TVertex Target { get; }

Property Value

TVertex