Exemple #1
0
        private string CalculateShortestPath(char sourceNode, char destinationNode)
        {
            AbstractGraphPath <char> shortestPath = ShortestPathCalulator.GetShortestPath(_graph, sourceNode,
                                                                                          destinationNode);
            string result = shortestPath == null ? "NO SUCH ROUTE" : shortestPath.PathWeight.ToString();


            return(result);
        }
Exemple #2
0
        private void FillPredecessor(AbstractGraphPath <TNode> graphPath, TNode node)
        {
            TNode predecessor;

            if (_predessorNodes.TryGetValue(node, out predecessor))
            {
                graphPath.Path.Insert(0, predecessor);
                FillPredecessor(graphPath, predecessor);
            }
        }
Exemple #3
0
        public override int CompareTo(AbstractGraphPath <TNode> other)
        {
            if (PathWeight == other.PathWeight)
            {
                return(0);
            }

            if (PathWeight == InfinityValue)
            {
                return(1);
            }
            if (other.PathWeight == InfinityValue)
            {
                return(-1);
            }

            if (PathWeight > other.PathWeight)
            {
                return(1);
            }
            return(-1);
        }