-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
implemented function for acyclic orientations #37345
Conversation
Is this related to #35075? Also, lint CI is failing. |
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.
Thank you for this first draft. I see that there is room for improvements. A first issue is that you implicitly assume that the vertices of the input graph are labeled 0..n-1
which is not always the case. To cope with this issue, you should use method relabel
to get both a copy of the input graph with suitable vertex labels and the mapping.
Below are a few comments.
To fix the failing doctests, you must expose the method in |
0f3bade
to
03e13c2
Compare
03e13c2
to
2a998dc
Compare
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.
We still have serious issues. We also have some minor issues regarding the coding style (too many parenthesis in unnecessary places, iteration of G.vertices()
when over G
is enough, etc.), but this can be fixed in a separate PR.
c324290
to
d28a2fb
Compare
Can you add doctests for small cases and check that the output is consistent. I don't think it is so far. sage: list(Graph().acyclic_orientations())
[Graph on 0 vertices]
sage: list(Graph(1).acyclic_orientations())
[Graph on 0 vertices]
sage: list(Graph(2).acyclic_orientations())
[Graph on 0 vertices] |
A graph without edge has no orientation, right ? so the method should not return an empty graph is such case. |
You could add at the beginning of the method: if not G.size():
# A graph without edge cannot be oriented
return |
Don't forget that the output of the doctests are now |
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.
LGTM.
We can certainly improve the code to get a faster method, but in a future PR. I will think about it.
5642f83
to
bef9946
Compare
Documentation preview for this PR (built with commit bef9946; changes) is ready! 🎉 |
Description
This PR introduces an efficient algorithm for generating all acyclic orientations of an undirected graph based on the work by Mathew B. Squire. The algorithm utilizes a recursive approach along with concepts from posets and subsets to improve the efficiency of acyclic orientation generation significantly.
Changes Made
Fixes #37253
📝 Checklist
⌛ Dependencies