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(); }
public void When_CreateExplicit_Expect_Explicit() { NodeEdgePair nodeEdgePair = new NodeEdgePair(1, 2); Assert.AreEqual(nodeEdgePair.nodeIndex, 1); Assert.AreEqual(nodeEdgePair.edgeIndex, 2); }
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)); } }
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); } }
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); }
private void When_CreateNegativeEdgeIndex_Expect_Exception_Helper() { NodeEdgePair nodeEdgePair = new NodeEdgePair(1, -2); }
private void AccessDefaultEdgeIndex() { NodeEdgePair nodeEdgePair = new NodeEdgePair(); int myInt = nodeEdgePair.edgeIndex; }
private void AccessDefaultNeighborNodeIndex() { NodeEdgePair nodeEdgePair = new NodeEdgePair(); int myInt = nodeEdgePair.nodeIndex; }