Repository navigation
fix multigraph isomorphism tests and fix support in ISMAGS and in VF2pp - #8616
Conversation
rossbar
left a comment
There was a problem hiding this comment.
Generally LGTM, another great improvement to the isomorphism package!
The test failure on the Wikipedia graph looks real, so that should be addressed (I haven't dived into it [yet]).
Everything else looks good though, so I will approve conditioned on fixing the broken wiki test!
rossbar
left a comment
There was a problem hiding this comment.
I had a chance to look at this again (including the latest 2 commits) - my approval stands!
|
I have added more tests that compare MultiGraph vs Graph and MultiDiGraph vs DiGraph. Anyway, its tested now. (thanks to the CI failure from test_ismags.py upon the first push in this PR) |
The existing multigraph tests for isomorphism were flawed in that they never had any multiedges (see below).
This PR updates the tests to ensure the multiedges intended to be created actually are making it into the graph. It also adds a few tests just for multigraphs. And it adds checks that all morphisms are found for the suite of graph tests. That means we have to know what all the morphisms are! And I changed the names of many tests from
*_subgraph_*to*_SG_*(cant help myself I guess)The new tests revealed a couple of failures for ismags, which is expected because ismags only recently supported multigraphs and it wasn't being tested well. So the 2nd commit here adds code to account for multiedges in two critical places: when computing degree and when checking that the number of edges between two nodes matches for candidate node-pairs. That fixed the errors for ISMAGS. There was also one failure for vf2pp multigraphs. The 3rd commit holds the fix for vf2pp.
After this PR
vf2ppandismagsagree withvf2on all these tests. And the tests have been expanded slightly, with new tests and also with known ground truth for number of morphisms between specific graphs.details
The test trouble with multiedges was due to my adding copies of existing edges using 3-tuples instead of 2-tuples. Usually we want to use 3-tuples for multigraphs. But if we need to add more edges, using a 3-tuple just adds the same edge multiple times, rather than creating new edges. The fixed code is, e.g.:
And the silently broken version used
G.edgesinstead ofG.edges(). Usually you want that, but not to create new edges. In one specific graph I switched from this shot-gun approach to adding multiedges to adding a targeted multiedge. I should do that for more of the test graphs. Adding arbitrary multiedges quickly reduces symmetries and isomorphism counts. With targeted edges we can keep multiple isomorphisms even for MultiDiGraph cases.