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
TVertexThe vertex type.
TWeightThe numeric weight type.
- Inheritance
-
ShortestPathResult<TVertex, TWeight>
- Inherited Members
Constructors
ShortestPathResult(TVertex, TVertex)
Initializes an unreachable result.
public ShortestPathResult(TVertex source, TVertex target)
Parameters
sourceTVertexThe path's start vertex.
targetTVertexThe 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
sourceTVertexThe path's start vertex.
targetTVertexThe path's end vertex.
distanceTWeightThe total path weight.
pathIReadOnlyList<TVertex>The vertices from
sourcetotargetinclusive.
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
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