Skip to content

Prims algorithm for sparse graphs needs some more elaboration #1426

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

Open
notimeforcaution opened this issue Feb 16, 2025 · 3 comments
Open

Comments

@notimeforcaution
Copy link

Link: https://cp-algorithms.com/graph/mst_prim.html#sparse-graphs-om-log-n

Edge in all the other places across document contains the weight and the already-selected node to which it is directed towards. For example: The i element in vector<Edge> min_e(N) implies that the smallest cost with which it can be connected to an already-selected node is 'w' and that already-selected node is 'to'.

However, in the implementation for sparse graphs, the set<Edge> contains all edges which connect selected to not-selected nodes, where 'to' now contains a node which is not already selected.

Implying at one place the to in Edge refers to selected nodes, whereas in other places it refers to non-selected nodes. While the algorithm still works best, but I think this bit can be clarified.

@notimeforcaution
Copy link
Author

I am happy to take this up and send a fix for this, but I think non-contributors cannot update the assignee for this issue.

Tagging maintainers for this: @jxu, @mhayter @Kostero; in-case you feel this is already explained well, and I am missing some bit, feel free to suggest otherwise.

@mhayter
Copy link
Contributor

mhayter commented Feb 18, 2025

I'm a little confused on the issue right now, though I'm not that familiar with the article.

As a rule, any contribution is welcome. We don't really assign stuff as we don't have dedicated enough members nor do we know the expertise of the individual.

If you believe that there could be some clarifying text, feel free to write it and submit a pull request.

That will be taken more seriously and have a more thorough review.

@notimeforcaution
Copy link
Author

notimeforcaution commented Feb 18, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants