Repository navigation
BUG: Group betweenness skips adjustments if any sigma is zero - #8881
Conversation
rossbar
left a comment
There was a problem hiding this comment.
Thanks @dschult ! The bugfix is obviously the motivation, but I'm very much in favor of this refactor - it still takes some time/reading to sink in, but I do find it easier to follow than the original. I think the biggest improvement on that front (for my understanding anyway) was the switch away from tracking the three d{xyv} variables and instead modifying the PB_ and sig_ dicts directly when needed. Also, the getting rid of another state-snapshot by eliminating the _m_v deep copies is a very nice improvement 🎉
I still haven't had time to read the underlying paper(s) from which the formula is drawn so I haven't compared the implementation here to the reference(s); however, I did take the time to go through and compare the formulae at each condition to the current implemenation and they do seem consistent (though as noted the conditions under which they are skipped has changed - hence the bugfix!).
FWIW this is an alternative to #8854, which @amcandio pointed out failed on an additional weighted test case. That case was added in #8880 - so just to doublecheck I merged all of the tests together across the three PRs and made sure this passed - which it did 🚀
So - same deal here as #8880 - I approve the PR but will hold off merging until draft status is dropped. Thanks again @dschult !
This PR builds on the group betweenness of the sigma typo #8879. That PR should be merged first. It doesn't interact with #8880 and so can be reviewed separately.
This fixes the if-logic in
group_betweeness_centralityto no longer skip all 3 adjustments when considering a group nodevwhen a denominator terms for any of the 3 is zero. Only the adjustment that has a zero divisor should be ignored.Tests from #8666 are included and fixed.
Fixes #8827
The if-structure was getting long and repetitive and hard to read -- and it involved many lookups in the inner loop that only changed when an outer loop changed. So I restructured the nested loops. The outer loop must be over
vsoPB_m[v][v]is correctly updated when it is added to the totalGBC. So the nesting stays the same. But at each nesting level we now store the lookups that don't depend on the next inner level. At the core we have 3 if-clauses for the 3 kinds of adjustments that might be needed: Orderx-v-y, Orderv-x-yand Orderx-y-v. The adjustments are made inside each of the 3 if statements. I'm hoping that is easier to read than initializing the changes to 0, using the if to update them to nonzero and then applying the change in every case. Here whenever the change would have been zero, we just don't do the adjustment.The extra dicts
sigma_m_vandPB_m_vare not needed -- they duplicatedsigma_mandPB_min case we needed an old value before the updating overwrote it. That was written in the pseudo code of the article. But we had ordered the assignment statements so the extra copy was not needed. So I just removed them. We update the*_mdicts directly.This fix allows the new tests to pass. So we are getting correct answers when we get answers now.
We still don't have the KeyErrors handled. Thats next.
Still to do:
endpoints=Trueand figure out how to make it meaningful, or remove that option.prominent_group_*,group_degree_*andgroup_closeness_*.