public NodeGraphDTO CalculateShortestPath(NodeGraphDTO startNode, NodeGraphDTO endNode) { startNode.CurrentDistance = 0; NodeGraphDTO currentNode = null; BinaryTree unsettledTree = new BinaryTree(1); unsettledTree.Add(startNode); while (!unsettledTree.IsEmpty()) { currentNode = unsettledTree.GetMin(); currentNode.Unsettled = false; if (currentNode.Equals(endNode)) { return(currentNode); } foreach (Edge edge in currentNode.Node.EdgeStartNodeNavigation) { NodeGraphDTO adjacentNode = edge.EndNodeNavigation.NodeGraphDTO; double edgeWeight = edge.DistanceInMeters; if (!adjacentNode.Settled) { CalculateMinimumDistance(adjacentNode, edgeWeight, currentNode, unsettledTree); } } Utils.PocetSpracovanychVrcholov++; currentNode.Settled = true; } return(null); }
private bool CalculateShortestPathR(NodeGraphDTO startNode) { NodeGraphDTO currentNode = GetLowestDistanceNode(unsettledTreeR); if (currentNode.Settled) { return(true); } foreach (Edge edge in currentNode.Node.EdgeEndNodeNavigation) { NodeGraphDTO adjacentNode = edge.StartNodeNavigation.NodeGraphDTO; double edgeWeight = edge.DistanceInMeters; if (!adjacentNode.SettledR) { CalculateMinimumDistance(adjacentNode, edgeWeight, currentNode, unsettledTreeR); if (adjacentNode.Equals(startNode)) { settledNodesB.Add(adjacentNode); } if (!adjacentNode.UnsettledR) { unsettledTreeR.Add(adjacentNode); adjacentNode.UnsettledR = true; } } } Utils.PocetSpracovanychVrcholov++; currentNode.SettledR = true; return(false); }
private bool PathContainsNode(NodeGraphDTO nodeI, NodeGraphDTO nodePath, int kk) { NodeGraphDTO node = nodePath; int k = kk; int xk; while (node.MultiLabelMark[k - 1].Xk != 0) { xk = node.MultiLabelMark[k - 1].Xk; node = node.MultiLabelMark[k - 1].X; if (node.Equals(nodeI)) { return(true); } k = xk; } return(false); }