Repository navigation
Fix for issue #7645: Do not preserve 'cw' and 'ccw' attributes in PlanarEmbedding.to_undirected() - #7750
Conversation
|
Thank you for putting this together @Schwarf These changes are made to the base class methods. But they should only apply for the PlanarEmbedding subclass. That is, someone who happens to create edge attributes named 'cw' will lose those attributes when they haven't ever used the planarity code. Can you move these changes to methods in the PlanarEmbedding class? |
|
Hi @dschult , |
|
My update has now added an overload of the Thank you for your support. Looking forward to your feedback. |
rossbar
left a comment
There was a problem hiding this comment.
My update has now added an overload of the to_undirected() method to the class PlanarEmbedding. I have removed the parameter reciprocal and corresponding functionality, because in my understanding its not relevant for planarity. Am I correct?
For the as_view parameter I am actually not sure if its useful or not. I left the parameter but did not write a test (yet), until ist confirmed that this functionality is wanted in class PlanarEmbedding.
My immediate reaction is that both as_view and reciprocal should be supported, if for no other reason than to maintain consistency with the API of the base class.
Re: as_view - AFAIK there's no (builtin) way to filter edge attributes in graph views, so an as_view=True will result in a graph view that still has the cw and ccw attributes on the edges. My current opinion is that this shouldn't be a blocker for now.
Re: reciprocal - I think it's a worthwhile feature to keep, even if it's not directly relevant for any sort of planarity analyses.
…` variable using `@pytest.mark.parametrize`.
ee520eb to
fee3140
Compare
dschult
left a comment
There was a problem hiding this comment.
Thanks for putting it into the PlanarEmbedding class.
The code looks fine. I probably would have made the as_view and reciprocal raise exceptions if used, but this is fine too. (the concept of views of planar embeddings seems strange to me; and all valid embeddings should have half-edges in both directions for every edge so reciprocal would only be needed for invalid embeddings.)
My suggestions are about the docs -- mostly about reference to "the original graph" being shifted to "the PlanarEmbedding" and related shifts away from the notation that the planar graph is some sort of directed graph when it is actually a representation of an undirected graph that happens to use a DiGraph super-class. You can change these suggestions by using local changes/commits. The github "add suggestion" feature makes it easy for me to suggest, but not as easy for you to adapt that to what you want. So use whatever you need to.
|
Thank you for the detailed feedback! I appreciate your points, especially regarding the wording in the documentation. You’re absolutely correct that my description of the method was misleading, and I will make sure to update it to reflect the correct terminology and intent. I also think your suggestion to raise exceptions for as_view and reciprocal is an excellent idea. Providing immediate feedback to users about the unusual nature of the PlanarEmbedding graph is a great way to improve usability and prevent potential confusion. I’ll incorporate this change into the method as well. |
…and 'reciprocal' and corresponding tests.
dschult
left a comment
There was a problem hiding this comment.
Thanks for these changes. I only have minor tweaks here.
Update docu Co-authored-by: Dan Schult <[email protected]>
Update docu Co-authored-by: Dan Schult <[email protected]>
Remove unreachable legacy code Co-authored-by: Dan Schult <[email protected]>
|
The automated close occurs if you put special text into the PR posting that connects the PR to the issue, or if someone has connected this PR to the issue in the Development section on the right sidebar of this page. Those are the two ways I know of. To use text to connect the PR to the issue, put |
I propose this fix for issue #7645. The changes ensure that the 'cw' and 'ccw' attributes are not preserved for both graphs and multi-graphs in the result of PlanarEmbedding.to_undirected().
I have included tests to verify that the issue is resolved.
I would be grateful for any feedback or suggestions to improve this PR. I am more than happy to incorporate any necessary changes based on the review. Thank you for your time and guidance!
Fixes #7645