Fix GraphicMatroid.is_isomorphic ground set size check - #42574
Fix GraphicMatroid.is_isomorphic ground set size check#42574gouravchahar13 wants to merge 3 commits into
Conversation
|
@gmou3 Please Review this and add it |
|
I don't think this check suffices. You may have the same size, but non-isomorphic matroids before simplification. |
|
On it |
|
This doesn't work if the ground set has size <4, see for example: K = Graph(multiedges=True) print(M1.is_3connected()) G = Graph(multiedges=True, loops=true) print(M1.size(), M2.size()) Your fix should work as long as the ground set of M1 has size >= 4. By Oxley's Matroid Theory (2011), Proposition 8.1.9, a graph G with no isolated vertices and |E(G)| >= 4 has M(G) 3-connected iff G is simple and 3-connected. So if other is Or, instead of testing matroid connectivity, you could just test the corresponding graphs
I hope this works out mathematically, I think it does but I'm not fully sure, and I also don't know which version would be more efficient. |
|
@slnkno3 I think the 3 bullet-point approach is correct (@gouravchahar13 can you implement this?). A nice idea for a future PR: implement an |
Yes , I have started already |
What's the definition of |
@dcoudert Two graphs are 2-isomorphic if one graph can be transformed into the other by a sequence of three types of operations: vertex identification (when the vertices belong to different components), vertex cleaving (when the vertex is a cut vertex), and twisting (also called Whitney twists). Vertex identification can be used to make a disconnected graph connected, while vertex cleaving can reverse this operation when a cut vertex is present. A Whitney twist is performed on a graph with a 2-vertex cut. Let u and v be the two vertices of this cut. We split the graph at these vertices, replacing u by two vertices u_1,u_2 and v by two vertices v_1,v_2, thereby separating the graph into two parts. Instead of identifying the vertices back in the original way, we interchange the identifications: we identify u_1 with v_2 and u_2 with v_1. An example of this twisting and the definition of 2-isomorphism can be found in Oxley's Matroid Theory, Whitney's 2-isomorphism theorem states that two graphs have the same graphic matroid if and only if they are 2-isomorphic. |
|
@slnkno3 @gmou3 I have updated the implementation, apart from the previous ground set size check (self.size() != other.size()) at the start I have added explicit invariant checks (loops and simplified matroid sizes) to handle small ground sets (E < 4) directly. |
|
I would recommend implementing the following approach (as suggested by @slnkno3), which seems more straightforward to me, and avoids the |E| < 4 case:
The overall structure would look something like this: |
|
Documentation preview for this PR (built with commit 3a68466; changes) is ready! 🎉 |
This PR resolves #42556
Summary
Added an early check to
GraphicMatroid._is_isomorphicto compare ground set sizes before testing for graph isomorphism.Problem
GraphicMatroid._is_isomorphicsimplifies underlying graphs by removing multiple edges and loops when comparing against a 3-connected graphic matroid. Because of this,M.is_isomorphic(M2)returnedTrueeven whenMhad more edges thanM2(e.g.,Changes
self.size() != other.size()check at the top of_is_isomorphic.GraphicMatroid._is_isomorphic.📝 Checklist
⌛ Dependencies
None