Skip to content

Implement Graph Coloring using Backtracking #737

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

Merged

Conversation

sozelfist
Copy link
Contributor

Description

See in the implementation.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I ran bellow commands using the latest version of rust nightly.
  • I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.
  • I ran cargo fmt just before my last commit.
  • I ran cargo test just before my last commit and all tests passed.
  • I added my algorithm to the corresponding mod.rs file within its own folder, and in any parent folder(s).
  • I added my algorithm to DIRECTORY.md with the correct link.
  • I checked COUNTRIBUTING.md and my code follows its guidelines.

@sozelfist sozelfist requested review from imp2002 and vil02 as code owners June 6, 2024 03:45
@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.05%. Comparing base (f8096d2) to head (d6fbf0d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #737      +/-   ##
==========================================
+ Coverage   95.04%   95.05%   +0.01%     
==========================================
  Files         305      306       +1     
  Lines       22674    22736      +62     
==========================================
+ Hits        21550    21612      +62     
  Misses       1124     1124              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

sozelfist and others added 2 commits June 27, 2024 07:59
- Use `Vec<Vec<bool>>` to represent the adjacency matrix to make the code more readable and slightly more efficient in terms of memory usage.
- Use `std::mem::take` to avoid unnecessary cloning while maintaining the original behavior of the algorithm
- Add some edge tests
@sozelfist
Copy link
Contributor Author

Can you help a look on this PR, @vil02?

- Add custom error `GraphColoringError` to handle the exceptional cases where the graph is empty or not squared
- Adjust the `is_valid_color` method to make the implementation handle the directed graphs
- Add tests for directed graphs
@sozelfist sozelfist requested a review from vil02 June 28, 2024 03:03
@sozelfist
Copy link
Contributor Author

sozelfist commented Jun 29, 2024

Let's have a look, @vil02?

@sozelfist sozelfist requested a review from vil02 July 1, 2024 02:13
@sozelfist
Copy link
Contributor Author

Let's have a final look, @vil02.

@vil02 vil02 merged commit 510bbb3 into TheAlgorithms:master Jul 1, 2024
4 checks passed
@sozelfist sozelfist deleted the feat/backtracking/graph_coloring branch July 2, 2024 01:00
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

Successfully merging this pull request may close these issues.

3 participants