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

Edge coloring on graphs #7397

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

Sreelaxme
Copy link

This pull request introduces an edge coloring algorithm within the edge_coloring() function. The function now returns a dictionary where each edge is a key, with corresponding values representing the assigned colors.
We have already created a pull request for edge coloring in bipartite graphs (#7138) which gives optimal coloring of bipartite graphs.

@padath314
Copy link

@dschult Could you please check this out ? I've explained our implementation in brief in this conversation.

@dschult
Copy link
Member

dschult commented Apr 15, 2024

Thanks for this @padath314 and @Sreelaxme (and for the bipartite PR).
These are interesting algorithms. I hope to get to take a closer look soon. :)

Copy link
Member

@dschult dschult left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is encouragingly similar to the bipartite code. I put a few comments, but they are so similar to the bipartite comments it seems like the first step will be to update this code to match. Thanks!

networkx/algorithms/coloring/edge_coloring.py Outdated Show resolved Hide resolved
d + 1 colors. Let u and v be distinct non-adjacent vertices of G.
Then there exists a proper edge coloring using d + 1 colors
such that the same color missing at both u and v.
https://iuuk.mff.cuni.cz/~rakdver/kgii/lesson20-6.pdf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make a References section with the full reference to this paper. Links rarely last more than a few years (except for the DOI link to the article). Full reference is more likely to last without additional maintenance.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are actually not able to find the DOI link since our reference is a lecture note.

G = G.copy()
degrees = dict(G.degree())
delta = max(degrees.values())
colors = set(range(delta + 1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use the range for colors instead of the set.
And make u_colors be the dict used_colors[u] and only use the keys() when doing set operations.
(similar comment to the bipartite version)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are keeping the colors as set to make it easier to find available colors using set difference.

networkx/algorithms/coloring/edge_coloring.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants