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

[ALGO] Prim's Minimum Spanning Tree #51

Closed
4 of 6 tasks
bobluppes opened this issue Aug 6, 2023 · 2 comments · Fixed by #103
Closed
4 of 6 tasks

[ALGO] Prim's Minimum Spanning Tree #51

bobluppes opened this issue Aug 6, 2023 · 2 comments · Fixed by #103
Assignees
Labels
enhancement New feature good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@bobluppes
Copy link
Owner

bobluppes commented Aug 6, 2023

Prim's Minimum Spanning Tree

Prim's algorithm is a greedy algorithm which finds a minimum spanning tree for a (weighted) undirected graph. See the wikipedia entry for more details.

Syntax

The algorithm should have the following syntax:

/**
 * Computes the minimum spanning tree (MST) of a graph using Prim's algorithm.
 *
 * @tparam V The vertex type of the graph.
 * @tparam E The edge type of the graph.
 * @param graph The input graph.
 * @param start_vertex The starting vertex for the MST construction.
 * @return An optional containing a vector of edges forming the MST if it exists, 
 *         or an empty optional if the MST doesn't exist (e.g., graph is not connected).
 */
template <typename V, typename E>
[[nodiscard]] std::optional<std::vector<typename graph<V, E, graph_type::UNDIRECTED>::edge_t>>
prim_minimum_spanning_tree(const graph<V, E, graph_type::UNDIRECTED>& graph, vertex_id_t start_vertex);

This should live in the graaf::algorithm namespace under include/graaflib/algorithm/minimum_spanning_tree.h.

Definition of Done

This issue is done when:

  • The algorithm is implemented
  • The new function has a javadoc-style comment explaining the interface
  • Appropriate tests are added under test/graaflib/algorithm/minimum_spanning_tree_test.cpp
  • A test coverage of at least 95% is reached
  • A documentation entry is added under docs/docs/algorithms under the appropriate category
    • Just adding a short description and the algorithm syntax here is fine
    • See the wiki on how to build the documentation locally
  • The algorithm is added to the list of algorithms in README.md
@bobluppes bobluppes added enhancement New feature help wanted Extra attention is needed labels Aug 6, 2023
@bobluppes bobluppes added good first issue Good for newcomers and removed good first issue Good for newcomers labels Aug 6, 2023
@bobluppes bobluppes pinned this issue Aug 6, 2023
@bobluppes bobluppes added the good first issue Good for newcomers label Aug 7, 2023
@bobluppes bobluppes added this to the release 1.0.0 milestone Aug 9, 2023
@bobluppes bobluppes self-assigned this Aug 10, 2023
@bobluppes bobluppes unpinned this issue Aug 13, 2023
@unbalancedvariance
Copy link
Contributor

Hey can i work on this issue?

@bobluppes
Copy link
Owner Author

Hey can i work on this issue?

Hi, this has been in progress for quite some 😬
All logic should already be there, so I will aim to finish up the tests this week and open the PR.

I hope the other issue regarding negative weight cycles looks interesting to you as well. If you have any proposals for new algorithms to implement, feel free to open an issue or discuss it on our discord. I will create new algorithm tickets coming week as well.

bobluppes added a commit that referenced this issue Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants