Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUnion-Find algorithm for finding components of a Graph #764
Comments
We want a benchmark that proves that it is a better solution. |
i want to work on this. |
I was just wondering how "Union-Find Approach using rank or path-compression" could be a better approach in finding the number of connected components. It'll take O(n log n) while the dfs approach works in O(n). |
Why write all this theoretical text?? Write up both algorithms and a benchmark instead. |
I have added Pull Request #773 regarding this issue. |
@coderanant DFS will take O(E) and O(E) = [O(V), O(V2)]. |
@deadshotsb Sorry for not making it clear. |
Where is the benchmark? |
How am I supposed to write a benchmark? |
@coderanant The best method to write a benchmark according to test the algorithms based on some randomly generated Graphs and showing a relation between time and the size of graph for the algorithms under consideration. |
what is the current status of this issue, as far as i know i had merged the PR related to this issue, what the status of benchmark @coderanant ? |
Let's say you are given Q queries. Each query is to add an edge into a graph. After each query you are to return the amount of connected components in this graph. DFS is O(NQ), while DSU is (Q a(N)). |
Since this repository is presenting multiple algorithms from an educational perspective, older inefficient algorithm implementations would also be welcome along with faster and more efficient implementations. |
In that case I am confused as for why cclauss is obsessed with speed benchmarks. |
We want to be able to see the theoretical performance DFS is O(NQ), while DSU is (Q a(N)) as well as the actual performance 32 sec. vs. 97 sec. As your username says, let's test the item. ;-) |
Thanks for the clarification. |
If the "point" of this repo is to present algorithms from an "educational" perspective, what use are benchmarks? On a similar note, if the goal is to present algorithms from an "educational" perspective, the repo should do a better job of documenting/explaining each algorithm. |
Documentation is being updated. A major re-work in these regards can be found here https://kvedala.github.io/C-Plus-Plus. However, for this documentation to automatically stay up-to-date with latest commits, the code submitted must be properly structured and documented. |
Also, any help towards this herculean effort would be greatly appreciated |
A DFS approach has been added for finding the number of components of a graph, but an approach using Union-Find algorithm is more than welcomed.
An Union-Find Approach using rank or path-compression can be a better solution