コード例 #1
0
        private IWeighted <IEnumerable <char> > UniformCostSearch(
            char start, char goal,
            Dictionary <char, IEnumerable <IWeighted <char> > > next)
        {
            var descriptor = WeightedGraphDescriptor.Create(n => n, Function(next));

            return(Graph.UniformCostSearch(
                       EnumerableEx.Return(new Weighted <char>(start, 0)),
                       descriptor.Key,
                       descriptor.Next,
                       n => n == goal));
        }
コード例 #2
0
        private IWeighted <IEnumerable <char> > AStar(
            char start, char goal,
            Dictionary <char, IEnumerable <IWeighted <char> > > next,
            bool isConsistent, Dictionary <char, double> heuristic)
        {
            var descriptor = WeightedGraphDescriptor.Create(n => n, Function(next));

            return(Graph.AStar(
                       EnumerableEx.Return(new Weighted <char>(start, 0)),
                       descriptor.Key,
                       descriptor.Next,
                       n => n == goal,
                       Heuristic.Create(F(heuristic), isConsistent)));
        }