Skip to content

Commit

Permalink
Merge pull request #290 from Aniket-debug/Aniket-week-1
Browse files Browse the repository at this point in the history
GSoC 2023: Aniket Agarwal Week 1
  • Loading branch information
Aniket-debug committed Jun 5, 2023
2 parents 81bcd0c + cd7791d commit a090974
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions doc/src/pgRouting-introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ This Release Contributors
Individuals in this release (in alphabetical order)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Aniket Agarwal,
Ashish Kumar,
Cayetano Benavent,
Daniel Kastl,
Expand Down
28 changes: 14 additions & 14 deletions include/yen/pgr_ksp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Pgr_ksp : public Pgr_messages {
m_start(0),
m_end(0),
m_K(0),
m_heap_paths(false) {
m_heap_paths(false) { //! heap is for debuging purpose to check whether the algorithm is running well or not
m_vis = new Visitor;
}
~Pgr_ksp() {
Expand Down Expand Up @@ -100,12 +100,12 @@ class Pgr_ksp : public Pgr_messages {
auto paths = get_results();
if (!m_heap_paths && paths.size() > m_K) paths.resize(m_K);

return paths;
return paths; //! contain K shortest Paths
}

void clear() {
m_Heap.clear();
m_ResultSet.clear();
m_Heap.clear(); //! clearing heap_paths
m_ResultSet.clear(); //! clearing all the paths stored previously
}


Expand All @@ -125,20 +125,20 @@ class Pgr_ksp : public Pgr_messages {

protected:
//! the actual algorithm
void executeYen(G &graph) {
void executeYen(G &graph) {
clear();
curr_result_path = getFirstSolution(graph);
curr_result_path = getFirstSolution(graph); //! it will give the first shortest path
m_vis->on_insert_first_solution(curr_result_path);

if (m_ResultSet.size() == 0) return; // no path found
if (m_ResultSet.size() == 0) return; //! no path found

while (m_ResultSet.size() < m_K) {
while (m_ResultSet.size() < m_K) { //! looping till k shortest paths
doNextCycle(graph);
if (m_Heap.empty()) break;
if (m_Heap.empty()) break; //! if there will no k paths possible
curr_result_path = *m_Heap.begin();
curr_result_path.recalculate_agg_cost();
m_ResultSet.insert(curr_result_path);
m_Heap.erase(m_Heap.begin());
curr_result_path.recalculate_agg_cost();
m_ResultSet.insert(curr_result_path); //! inserting the ith shortest path in result
m_Heap.erase(m_Heap.begin()); //! removing the inserted path from heap_paths
}
}

Expand All @@ -147,7 +147,7 @@ class Pgr_ksp : public Pgr_messages {

//! Performs the first Dijkstra of the algorithm
protected:
Path getFirstSolution(G &graph) {
Path getFirstSolution(G &graph) { //! here first sortest path will be calculated using dijkstra algorithm
Path path;

path = algorithms::dijkstra(graph, m_start, m_end);
Expand All @@ -161,7 +161,7 @@ class Pgr_ksp : public Pgr_messages {

protected:
//! Performs the next cycle of the algorithm
void doNextCycle(G &graph) {
void doNextCycle(G &graph) {
for (unsigned int i = 0; i < curr_result_path.size(); ++i) {
int64_t spurNodeId = curr_result_path[i].node;

Expand Down

0 comments on commit a090974

Please sign in to comment.