Shields.Graphs/Graph.cs
/// <summary>
/// Gets the minimum-weight path to a goal using the A* algorithm.
/// </summary>
/// <typeparam name="TNode">The type of a node.</typeparam>
/// <typeparam name="TKey">The type of a node key.</typeparam>
/// <param name="sources">The set of nodes from which to start the search, weighted by their initial cost.</param>
/// <param name="key">The function which maps a node to its key.</param>
/// <param name="next">The function which maps a node to its adjacent nodes.</param>
/// <param name="goal">The goal predicate.</param>
/// <param name="heuristic">The heuristic function.</param>
/// <returns>The minimum-weight path, or null if none exists.</returns>
Gets the minimum-weight path to a goal using the A* algorithm.
Gets the minimum - weight path to a goal using the A * algorithm .
public static IWeighted<IEnumerable<TNode>> AStar<TNode, TKey>(
            this IEnumerable<IWeighted<TNode>> sources,
            Func<TNode, TKey> key,
            Func<TNode, IEnumerable<IWeighted<TNode>>> next,
            Func<TNode, bool> goal,
            IHeuristic<TNode> heuristic)
        {
            if (heuristic.IsConsistent)
            {
                return AStarConsistent<TNode, TKey>(sources, key, next, goal, heuristic.Evaluate);
            }
            else
            {
                return AStarInconsistent<TNode, TKey>(sources, key, next, goal, heuristic.Evaluate);
            }
        }
public static IWeighted < IEnumerable < TNode > > AStar < TNode , TKey > ( this IEnumerable < IWeighted < TNode > > sources , Func < TNode , TKey > key , Func < TNode , IEnumerable < IWeighted < TNode > > > next , Func < TNode , bool > goal , IHeuristic < TNode > heuristic ) { if ( heuristic . IsConsistent ) { return AStarConsistent < TNode , TKey > ( sources , key , next , goal , heuristic . Evaluate ) ; } else { return AStarInconsistent < TNode , TKey > ( sources , key , next , goal , heuristic . Evaluate ) ; } }
Gets the minimum-weight path to a goal using the A* algorithm.
Gets the minimum - weight path to a goal using the A * algorithm .
The minimum-weight path, or null if none exists.
The minimum - weight path or null if none exists .
IEnumerable<IWeighted<TNode>>
this
<not_specific>
key
Func<TNode, TKey>
The function which maps a node to its key.
The function which maps a node to its key .
next
Func<TNode, IEnumerable<IWeighted<TNode>>>
The function which maps a node to its adjacent nodes.
The function which maps a node to its adjacent nodes .
goal
Func<TNode, bool>
The goal predicate.
The goal predicate .
heuristic
IHeuristic<TNode>
The heuristic function.
The heuristic function .
sources
<not_specific>
The set of nodes from which to start the search, weighted by their initial cost.
The set of nodes from which to start the search weighted by their initial cost .
typeparam
The type of a node.
The type of a node .
typeparam
The type of a node key.
The type of a node key .