/** * Do the work */ protected void DetermineShortestPaths(BaseVertex sourceVertex, BaseVertex sinkVertex, bool isSource2sink) { // 0. clean up variables Clear(); // 1. initialize members BaseVertex endVertex = isSource2sink ? sinkVertex : sourceVertex; BaseVertex startVertex = isSource2sink ? sourceVertex : sinkVertex; startVertexDistanceIndex.Add(startVertex, 0d); startVertex.SetWeight(0d); vertexCandidateQueue.add(startVertex, startVertex.GetWeight()); // 2. start searching for the shortest path while (!vertexCandidateQueue.isEmpty()) { BaseVertex curCandidate = vertexCandidateQueue.poll(); if (curCandidate.Equals(endVertex)) { break; } determinedVertexSet.Add(curCandidate); UpdateVertex(curCandidate, isSource2sink); } }
/// <summary> /// Do the work /// </summary> protected internal virtual void determine_shortest_paths(BaseVertex source_vertex, BaseVertex sink_vertex, bool is_source2sink) { // 0. clean up variables clear(); // 1. initialize members BaseVertex end_vertex = is_source2sink ? sink_vertex : source_vertex; BaseVertex start_vertex = is_source2sink ? source_vertex : sink_vertex; _start_vertex_distance_index[start_vertex] = 0d; start_vertex.set_weight(0d); _vertex_candidate_queue.Enqueue(start_vertex, 0); // 2. start searching for the shortest path while (_vertex_candidate_queue.Count() != 0) { BaseVertex cur_candidate = _vertex_candidate_queue.Dequeue(); if (cur_candidate.Equals(end_vertex)) { break; } _determined_vertex_set.Add(cur_candidate); _improve_to_vertex(cur_candidate, is_source2sink); } }
public bool IsValidEdge(BaseVertex currentVertex, BaseVertex siblingVertex) { return(!currentVertex.Equals(siblingVertex)); }