< Summary

Information
Class: MoreStructures.Graphs.ShortestDistance.BidirectionalAStarShortestDistanceFinder
Assembly: MoreStructures
File(s): /home/runner/work/MoreStructures/MoreStructures/MoreStructures/Graphs/ShortestDistance/BidirectionalAStarShortestDistanceFinder.cs
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 47
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%

File(s)

/home/runner/work/MoreStructures/MoreStructures/MoreStructures/Graphs/ShortestDistance/BidirectionalAStarShortestDistanceFinder.cs

#LineLine coverage
 1using MoreStructures.PriorityQueues;
 2
 3namespace MoreStructures.Graphs.ShortestDistance;
 4
 5/// <summary>
 6/// A <see cref="IPotentialBasedShortestDistanceFinder"/> implementation based on the bidirectional A* algorithm,
 7/// which combines the goal-oriented heuristic of the A* algorithm and the double search approach of the bidirectional
 8/// Dijkstra's algorithm.
 9/// </summary>
 10/// <remarks>
 11///     <para id="requirements">
 12///         <inheritdoc cref="AStarShortestDistanceFinder" path="/remarks/para[@id='requirements']"/>
 13///     </para>
 14///     <para id="algorithm">
 15///     ALGORITHM
 16///     <br/>
 17///     - Same as <see cref="AStarShortestDistanceFinder"/>, but with the use of the "bidirectional search approach"
 18///       used in <see cref="BidirectionalDijkstraShortestDistanceFinder"/> to run Dijkstra's algorithm.
 19///     </para>
 20///     <para id="complexity">
 21///     COMPLEXITY
 22///     <br/>
 23///     - The bidirectional search cuts in half, in average, the exploration time of
 24///       <see cref="AStarShortestDistanceFinder"/>.
 25///       <br/>
 26///     - That improves average runtime, but doesn't change worst case scenarios and best case scenarios, since in
 27///       those scenarios the number of vertices to visit is fixed and equal to v and h, respectively, and irrespective
 28///       of whether the exploration is done unidirectionally or bidirectionally.
 29///       <br/>
 30///     - Therefore, Time Complexity is O(e + v * log(v)) in the worst case, O(h) in the best case and somewhere in
 31///       between, still lower than <see cref="AStarShortestDistanceFinder"/>, in all other cases.
 32///       <br/>
 33///     - Space Complexity is between O(h) and O(v).
 34///     </para>
 35/// </remarks>
 36public class BidirectionalAStarShortestDistanceFinder : PotentialBasedShortestDistanceFinder
 37{
 38    /// <inheritdoc cref="BidirectionalAStarShortestDistanceFinder"/>
 39    /// <param name="priorityQueueBuilder">
 40    /// A builder of a <see cref="IUpdatablePriorityQueue{T}"/> of <see cref="int"/> values, used by the algorithm to
 41    /// store edges with priority from the closest to the start, to the farthest.
 42    /// </param>
 43    public BidirectionalAStarShortestDistanceFinder(Func<IUpdatablePriorityQueue<int>> priorityQueueBuilder)
 3044        : base(new BidirectionalDijkstraShortestDistanceFinder(priorityQueueBuilder))
 3045    {
 3046    }
 47}