Repository navigation
Fix graph_hash iteration counts and DiGraph handling - #7834
Conversation
|
I think it would make sense if @dschult would review this, since he has been active in the original issue, but I assume I cannot assign a reviewer. Any other feedback is, of course, also welcome! |
dschult
left a comment
There was a problem hiding this comment.
Thanks for this! It is nice to see it all put together.
@MichaelMartini-Celonis can you review this too? Thanks!
I have some comments below, but the main question I have is what will this change for a user who has created hashes before and now updates the NetworkX version to this code. How can we describe the change and can we find words to tell them how to get the previous hash they got before with the new version? I'm hoping it is something like: "change the number of iterations to be one more than it used to be." And of course DiGraph hashes will change since the methodology changed and the previous ones were broken. I'm just hoping that for Graph there will be a way to match previous work.
At the least we need a Note in the doc_string explaining this impact of this change.
Thanks!
|
Thanks a lot to both of you for the extensive reviews! |
|
Based on your feedback I've made the following changes:
Todo:
Warning Hash values observed in outputs of Please let me know if I can further improve these warnings! |
|
PS: I have no idea why the coverage test now fails, it seems to timeout on a part of the code that I have not touched. So with a bit of luck it will be fine once I've finalised the documentation and resubmit it. |
dschult
left a comment
There was a problem hiding this comment.
This PR looks ready to me. I'm going to remove Draft status for this PR and ask for a final review. I have also added the milestone v3.5. If we don't get it in for that release we can change the warnings.
Summary:
- Issue discussed previously that is now put off until another PR: hashing collected labels instead of hashing collected hashes of labels.
- zero iterations case now handled
- warnings added in docs and when input
is_directed
@ThijsVromen can you:
- see what you think of the following wording suggestions
- add the version number 3.5 instead of TBD in the warnings.
- anything else before we give final reviews for this?
I approve this PR! (the suggestions are not blockers for merging)
Co-authored-by: Dan Schult <[email protected]>
|
Just to make sure I have a clear picture of the current state: This PR will change the results for the undirected case, and this change is necessary - i.e. is a bug and not a stylistic choice - is that right? |
This is correct. To be more precise, the results are changed for all directed graphs and for a subset of undirected graphs (those without node and/or edge attributes). Both changes are bugfixes. |
rossbar
left a comment
There was a problem hiding this comment.
Sounds like there's consensus on the change and the code LGTM, thanks @ThijsVromen @MichaelMartini-Celonis & @dschult !
Fixes #7806
Includes bugfixes for the issues discussed.
Does not cover the potential extension to
MultiGraphs.Extended testing, but note that a lot of the test in this module in depend on randomly generated graphs. We continued that here. However, that does not necessarily mean all edge-cases are covered (as the original bug showed).
Note that subgraph hashing requires hashing of initial labels for digest size testing. This is not necessarily (and thus omitted) for general graph hashing.
A small optimisation is also made to the original graph hashing method. It used to collect all labels calculated during execution in a counter, and hashed that to get the final graph hash. However, the WL algorithm only relies on the colouring (labels) calculated at the last iteration, so the current versionl only hashes those to obtain the final hash.