コード例 #1
0
        // Walk back through the predecessors to the one after source.
        private static NodeAndCost ExtractNextNodeFromTable(C5.IDictionary <Node, Entry> table, Object source,
                                                            Node destination)
        {
            var nextNodeAndCost = new NodeAndCost(table[destination].predecessor, table[destination].cost);

            while (nextNodeAndCost.node != null &&
                   Math.Abs(nextNodeAndCost.cost - float.MaxValue) > 0.01f &&
                   table[nextNodeAndCost.node].predecessor != source)
            {
                nextNodeAndCost.node = table[nextNodeAndCost.node].predecessor;
            }

            return(nextNodeAndCost);
        }
コード例 #2
0
        public static void Create(Graph graph)
        {
            foreach (var sourceNode in graph.nodeCollection.Nodes)
            {
                foreach (var destinationNode in graph.nodeCollection.Nodes)
                {
                    _NEXT_NODE_AND_COST_TABLE[new NodePair(sourceNode, destinationNode)] =
                        new NodeAndCost(null, float.MaxValue);
                }
            }

            foreach (var node in graph.nodeCollection.Nodes)
            {
                DikstrasSearch(graph.nodeCollection.Nodes, node);
            }
        }