예제 #1
0
        protected override void Traverse()
        {
            InitMinimumDistance();

            INode currentNode = StartNode;

            while (currentNode != EndNode)
            {
                currentNode.IsVisited = true;
                DiscoverCloudEdges(currentNode);

                NodeEdgePair nextNode = GetNextNode();
                CheckNextNode(nextNode);

                _nodePath.Add(nextNode.Node,
                              new NodeEdgePair
                {
                    Node = nextNode.Edge.GetOppositeNode(nextNode.Node, true),
                    Edge = nextNode.Edge
                });

                RemoveCloudEdge(nextNode.Edge);
                currentNode = nextNode.Node;
            }

            TraceBackMinDistancePath();
        }
예제 #2
0
        public void When_CreateExplicit_Expect_Explicit()
        {
            NodeEdgePair nodeEdgePair = new NodeEdgePair(1, 2);

            Assert.AreEqual(nodeEdgePair.nodeIndex, 1);
            Assert.AreEqual(nodeEdgePair.edgeIndex, 2);
        }
예제 #3
0
 private void CheckNextNode(NodeEdgePair nextNode)
 {
     if (nextNode == null)
     {
         throw new Exception(
                   string.Format("No path found from node {0} to node {1}", StartNode.ID, EndNode.ID));
     }
 }
예제 #4
0
        public override bool Equals(Object obj)
        {
            //Check for null and compare run-time types.
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return(false);
            }
            else
            {
                NodeEdgePair other = (NodeEdgePair)obj;

                return(nodeIndex == other.nodeIndex &&
                       edgeIndex == other.edgeIndex);
            }
        }
예제 #5
0
        private void TraceBackMinDistancePath()
        {
            INode currentNode = EndNode;

            while (currentNode != StartNode)
            {
                NodeEdgePair previousNode = _nodePath[currentNode];
                Result.Nodes.Add(currentNode);
                Result.Edges.Add(previousNode.Edge);
                Result.TotalWeight += previousNode.Edge.Weight;

                currentNode = previousNode.Node;
            }

            Result.Nodes.Add(StartNode);
        }
예제 #6
0
 private void When_CreateNegativeEdgeIndex_Expect_Exception_Helper()
 {
     NodeEdgePair nodeEdgePair = new NodeEdgePair(1, -2);
 }
예제 #7
0
 private void AccessDefaultEdgeIndex()
 {
     NodeEdgePair nodeEdgePair = new NodeEdgePair();
     int          myInt        = nodeEdgePair.edgeIndex;
 }
예제 #8
0
 private void AccessDefaultNeighborNodeIndex()
 {
     NodeEdgePair nodeEdgePair = new NodeEdgePair();
     int          myInt        = nodeEdgePair.nodeIndex;
 }