Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC 2023: Aniket Agarwal Week 1 #290

Merged
merged 2 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a false statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so What is the significance of heap_paths from the user's perspective?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First define user

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the topic about user on the gitter chat

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the statement is false, because it is not for debugging purposes. The final user might want everything that was calculated, why who knows, only the final user knows why they need it.

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