-
Notifications
You must be signed in to change notification settings - Fork 268
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
Lowest common ancestor added #391
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #391 +/- ##
=============================================
- Coverage 98.574% 98.504% -0.071%
=============================================
Files 25 25
Lines 3297 3343 +46
=============================================
+ Hits 3250 3293 +43
- Misses 47 50 +3
|
@sHiVaNgI821 Please try to cover the read lines as well in https://app.codecov.io/gh/codezonediitj/pydatastructs/compare/391/diff |
pydatastructs/graphs/algorithms.py
Outdated
References | ||
========== | ||
|
||
.. [1] https://en.wikipedia.org/wiki/Topological_sorting#Kahn's_algorithm |
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.
Are binary lifting and Kahn's algorithm the same thing?
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.
No sorry I had to change the reference used. I'll do it right away.
pydatastructs/graphs/algorithms.py
Outdated
if not hasattr(algorithms, func): | ||
raise NotImplementedError( | ||
"Currently %s algorithm isn't implemented for " | ||
"performing topological sort on %s graphs." % (algorithm, graph._impl)) |
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 think you intend to refer to lowest common ancestor.
@@ -11,6 +11,7 @@ | |||
from pydatastructs.graphs.graph import Graph | |||
from pydatastructs.linear_data_structures.algorithms import merge_sort_parallel | |||
from pydatastructs import PriorityQueue | |||
import math |
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.
Is importing math necessary for binary lifting?
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.
Yes I suppose. I have used the log2 function from the math library in my code.
Added the lowest_common_ancestor method that returns the lowest common ancestor of two given vertices in a graph (an ancestor that is common to both vertices and farthest from the root vertex).
References to other Issues or PRs or Relevant literature
Brief description of what is fixed or changed
Other comments