-
-
Notifications
You must be signed in to change notification settings - Fork 342
Feat graph colouring #258
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
base: master
Are you sure you want to change the base?
Feat graph colouring #258
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds classic graph coloring algorithms (backtracking, greedy, Welsh–Powell) with validation and demonstrations, and also introduces Bidirectional BFS and the Viterbi algorithm with example usage.
- Adds graph coloring algorithms with chromatic number search and validation helpers
- Introduces Bidirectional BFS (shortest path) and Viterbi (HMM decoding) implementations
- Includes comprehensive, runnable examples; one extraneous file appears to be accidentally committed
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| graph_algorithms/graph_coloring.r | New graph coloring implementations (backtracking, greedy, Welsh–Powell), chromatic number calculation, validation, and example demos. |
| graph_algorithms/bidirectional_bfs.r | New Bidirectional BFS shortest-path implementation with example; contains a stray return at EOF that breaks script execution. |
| dynamic_programming/viterbi.r | New Viterbi algorithm with example usage for HMM decoding. |
| et --soft HEAD~1 | Appears to be an accidentally committed git log; should be removed. |
Comments suppressed due to low confidence (1)
et --soft HEAD~1:1
- This file appears to be an accidentally committed git log and does not belong in the repository. Please remove it from the PR.
�[33mcommit 7d4b7af52036b21abf54435f14250ef170351389�[m�[33m (�[m�[1;36mHEAD�[m�[33m -> �[m�[1;32mGraph_colouring�[m�[33m)�[m
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
et --soft HEAD~1:1
- This appears to be an accidental commit of a git log dump and does not belong in the repository. Please remove the file from the PR.
�[33mcommit 7d4b7af52036b21abf54435f14250ef170351389�[m�[33m (�[m�[1;36mHEAD�[m�[33m -> �[m�[1;32mGraph_colouring�[m�[33m)�[m
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
Comments suppressed due to low confidence (1)
et --soft HEAD~1:1
- This appears to be an accidental commit of git log output and not source code. Please remove this file from the repository and the PR.
�[33mcommit 7d4b7af52036b21abf54435f14250ef170351389�[m�[33m (�[m�[1;36mHEAD�[m�[33m -> �[m�[1;32mGraph_colouring�[m�[33m)�[m
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
et --soft HEAD~1:1
- This appears to be an accidental commit of a git log/metadata file, not source code. Please remove this file from the repository.
�[33mcommit 7d4b7af52036b21abf54435f14250ef170351389�[m�[33m (�[m�[1;36mHEAD�[m�[33m -> �[m�[1;32mGraph_colouring�[m�[33m)�[m
|
Please resolve conflicts |
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
et --soft HEAD~1:1
- This file "et --soft HEAD~1" appears to be Git command output that was accidentally committed. It should be removed from the repository as it's not part of the algorithm implementation and doesn't belong in version control.
�[33mcommit 7d4b7af52036b21abf54435f14250ef170351389�[m�[33m (�[m�[1;36mHEAD�[m�[33m -> �[m�[1;32mGraph_colouring�[m�[33m)�[m
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
et --soft HEAD~1:1
- This file appears to be a Git command output that was accidentally committed. Files with Git command names like "et --soft HEAD~1" should not be part of the repository. This file should be removed from the commit.
�[33mcommit 7d4b7af52036b21abf54435f14250ef170351389�[m�[33m (�[m�[1;36mHEAD�[m�[33m -> �[m�[1;32mGraph_colouring�[m�[33m)�[m
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
et --soft HEAD~1:1
- This file appears to be a Git command output that was accidentally committed. Files containing Git history or command outputs should not be added to the repository. This file should be removed from the PR.
�[33mcommit 7d4b7af52036b21abf54435f14250ef170351389�[m�[33m (�[m�[1;36mHEAD�[m�[33m -> �[m�[1;32mGraph_colouring�[m�[33m)�[m
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
et --soft HEAD~1:1
- This file appears to be a git log output that was accidentally committed. It should be removed from the repository and added to .gitignore if needed.
�[33mcommit 7d4b7af52036b21abf54435f14250ef170351389�[m�[33m (�[m�[1;36mHEAD�[m�[33m -> �[m�[1;32mGraph_colouring�[m�[33m)�[m
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
et --soft HEAD~1:1
- This file 'et --soft HEAD~1' appears to be Git command output that was accidentally committed. It should be removed from the repository as it's not a valid source file and contains Git history data that shouldn't be tracked.
�[33mcommit 7d4b7af52036b21abf54435f14250ef170351389�[m�[33m (�[m�[1;36mHEAD�[m�[33m -> �[m�[1;32mGraph_colouring�[m�[33m)�[m
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
et --soft HEAD~1:1
- This file appears to be a Git log output that was accidentally added to the repository. It should be removed from version control as it's not part of the codebase and was likely created by a mistyped Git command.
�[33mcommit 7d4b7af52036b21abf54435f14250ef170351389�[m�[33m (�[m�[1;36mHEAD�[m�[33m -> �[m�[1;32mGraph_colouring�[m�[33m)�[m
| } | ||
| } | ||
|
|
||
| for (c in 1:(n + 1)) { |
Copilot
AI
Oct 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop iterates up to n + 1, but the available vector is only allocated with size n + 1 at line 119. This creates unnecessary overhead and potential for confusion. The available vector and loop should both use size n since there can be at most n colors needed for any graph (one per vertex). Change line 119 to available <- rep(TRUE, n) and line 127 to for (c in 1:n).
|
Resolve conflicts |
• Assigns colors to graph vertices ensuring no adjacent vertices share the same color
• Uses backtracking approach for optimal solution
• Finds chromatic number (minimum colors needed)
• Implements greedy coloring for faster approximation
• Includes Welsh-Powell algorithm (degree-based ordering)
• Validates coloring solutions for correctness
• Demonstrates with multiple test cases (triangle, Petersen, bipartite, random graphs)
• Time complexity: O(m^V), Space complexity: O(V)
• Production-ready implementation with comprehensive examples