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

Lowest common ancestor added #391

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sHiVaNgI821
Copy link
Contributor

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

@codecov
Copy link

codecov bot commented May 17, 2021

Codecov Report

Merging #391 (1246149) into master (0f23c98) will decrease coverage by 0.070%.
The diff coverage is 93.478%.

@@              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     
Impacted Files Coverage Δ
pydatastructs/graphs/__init__.py 100.000% <ø> (ø)
pydatastructs/graphs/algorithms.py 98.861% <93.478%> (-0.631%) ⬇️

Impacted file tree graph

@czgdp1807
Copy link
Member

@sHiVaNgI821 Please try to cover the read lines as well in https://app.codecov.io/gh/codezonediitj/pydatastructs/compare/391/diff
Are they checks for corner cases? If so, then please add tests covering them.

References
==========

.. [1] https://en.wikipedia.org/wiki/Topological_sorting#Kahn's_algorithm
Copy link
Member

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?

Copy link
Contributor Author

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.

if not hasattr(algorithms, func):
raise NotImplementedError(
"Currently %s algorithm isn't implemented for "
"performing topological sort on %s graphs." % (algorithm, graph._impl))
Copy link
Member

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
Copy link
Member

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?

Copy link
Contributor Author

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.

@czgdp1807 czgdp1807 added the Please take over PRs that can be continued by anyone. label Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
miscellaneous_data_structures Please take over PRs that can be continued by anyone.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants