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] Welsh-Powell Algorithm #117

Closed
6 tasks
bobluppes opened this issue Sep 30, 2023 · 4 comments · Fixed by #118
Closed
6 tasks

[ALGO] Welsh-Powell Algorithm #117

bobluppes opened this issue Sep 30, 2023 · 4 comments · Fixed by #118
Assignees
Labels
enhancement New feature good first issue Good for newcomers hacktoberfest help wanted Extra attention is needed

Comments

@bobluppes
Copy link
Owner

Welsh-Powell Algorithm

The Welsh-Powell algorithm is a greedy graph coloring algorithm. It works by sorting the vertices by their degrees in descending order and then assigning colors in a manner that no two adjacent vertices share the same color. This algorithm is particularly efficient for coloring sparse graphs and is generally simpler to implement than other coloring algorithms.

Since it is a variant of the greedy coloring algorithm (which is already implemented under algorithm/coloring/greedy_graph_coloring.h), it would be nice if we could reuse that implementation.

More details on this variant of greedy coloring can be found in the wikipedia entry.

Syntax

The algorithm should have the following syntax:

/**
  * @brief Applies the Welsh-Powell greedy graph coloring algorithm to the given graph.
  * 
 * The function sorts the vertices by their degree in descending order, then attempts
 * to color the graph in a way that no two adjacent vertices share the same color.
 *
 * @tparam GRAPH The graph type.
 * @param graph The input graph to color.
 * @return std::unordered_map<vertex_id_t, int> An map from vertex ID to color if the graph could be colored, or an empty map otherwise.
 */
template <typename GRAPH>
std::unordered_map<vertex_id_t, int> welsh_powell_coloring(const GRAPH& graph);

This should live in the graaf::algorithm namespace under include/graaflib/algorithm/coloring/welsh_powell.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/coloring/welsh_powell_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 hacktoberfest good first issue Good for newcomers labels Sep 30, 2023
@toadkarter
Copy link
Contributor

Hi there, I would be happy to take this on. Would it be possible to have this issue assigned to me?

@GouraV-Chatterjee
Copy link
Contributor

I generated a PR on this issue..Since I am a beginner please do look into my PR and share your valuable feedback...Thank you!!

@bobluppes
Copy link
Owner Author

Hi there, I would be happy to take this on. Would it be possible to have this issue assigned to me?

Hi, seeing as you are already assigned on #115 I will go ahead and assign this to @GouraV-Chatterjee

Welcome both to Graaf!

@GouraV-Chatterjee
Copy link
Contributor

@bobluppes I have generated a PR regarding this issue....Please have a look!!!!Thanks:)

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 hacktoberfest help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants