-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(kernel): implement DSATUR coloring algorithm for vertices #245
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #245 +/- ##
==========================================
+ Coverage 78.97% 79.77% +0.80%
==========================================
Files 52 55 +3
Lines 6834 7065 +231
==========================================
+ Hits 5397 5636 +239
+ Misses 1437 1429 -8 ☔ View full report in Codecov by Sentry. |
TODO:
|
there's an issue in neighbors computation bc nodes on the edge have a single oriented dart as links
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.
I am not fully convinced by the implementation.
/// # Return | ||
/// | ||
/// The function will return the maximal used color, i.e. the `n_color_used - 1`. | ||
pub fn color<T: CoordsFloat>(cmap: &mut CMap2<T>) -> u8 { |
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.
Not sure if it is a good name. Perhaps the algorithm name will be better. Add to the description it is a distance-1 coloring of the vertices.
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.
I re-export the function as color_dsatur
in the coloring
module. I can switch it to dsatur
if you want
pub fn color<T: CoordsFloat>(cmap: &mut CMap2<T>) -> u8 { | ||
cmap.add_attribute_storage::<Color>(); | ||
|
||
// build graph data as a collection of (Vertex, Vec<Neighbors>) |
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.
Could this part be helpful elsewhere?
You can add a way to create a graph from a CMap. And use things like Coupe later ;).
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.
Could this part be helpful elsewhere? You can add a way to create a graph from a CMap.
Yeah, I think I can also make it generic enough to handle all possible adjacency types (e.g. here we're using vertex-vertex, but we could fetch incident faces for another usage).
And use things like Coupe later ;).
I actually wanted to try and use it, but I think all coloring algorithms of coupe are focused on balancing weights, rather than making independent subsets. Is that right?
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.
I'm actually going to implement my idea for graphes in another Pr, and I'll sync this branch with master to use it after.
// - not colored | ||
// - of highest saturation | ||
// - if there are multiple, take the one of highest degree | ||
crt_node = nodes |
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.
Can you comment on the complexity?
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.
I'll add it to the doc, but it's O(n²)
Description
Associated issue: closes #236
Content description:
add_attribute_storage
method toCMap2
for convenienceFollow-up
Aside from using it, I think the algorithm implementation can be modified to handle coloring on all types of I-cells, using a trait and the
enum_dispatch
crate to avoid dyn object lookup costs.