-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
feat: add Depth first search #2815
base: master
Are you sure you want to change the base?
feat: add Depth first search #2815
Conversation
I've updated the algorithm and added more test cases as per the feedback received. Please review the latest changes. Thank you! |
}; | ||
std::uint32_t n3 = 5, u3 = 0, v3 = 4; | ||
assert(graph::count_paths(graph3, u3, v3, n3) == 3); // There are 3 paths from node 0 to 4 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a test case for empty array
std::vector<std::vectorstd::uint32_t> graph5 = {{}};
this should return 0 as there is no path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made the latest changes as per your feedback. I hope this meets the requirements now. Looking forward to your review.
Description of Change
Checklist
Notes: The new function counts the number of unique paths between two nodes in a graph. It can be particularly useful in graph-related problems where pathfinding is necessary.