Credit the moved node's volume to the community it moved into - #178
Open
arpitjain099 wants to merge 1 commit into
Open
arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_last_step_weightedand_last_step_unweightedsearch for the best community for a node, then apply the move:mis the loop variable from the search above, so after the loop it holds whichever candidate happened to come last out ofset([i for x in L for i in x]) - {dct_A_v}, not the community the node actually moved into. The node goes tobest, but its volume is added tom. From then on the per-community volumes are wrong, and since the degree tax for every later move is computed fromVolA, the errors compound over the sweep.Changed both to
VolA[best].I measured it on 24 random hypergraphs (30 nodes, 40 edges of size 2 to 5, singleton start,
delta=0.01), comparing the modularity of the returned partition. 20 of 24 improved, mean 0.245 to 0.309. Individual seeds move both ways, which is expected of a greedy heuristic, and the run to run numbers wobble a little because the candidate loop iterates a set, but the direction is consistent.I did not add a test for it: for the same reason the results are not reproducible enough for a threshold assertion, and I did not want to add a flaky one. Happy to add something if you have a preference for how.
While reading this I noticed a separate issue in the same file, not touched here:
VolAandCtr/ctr_sizesare allocated withnp.repeat(0, n), which is int64, and then accumulateH.edges[e].weight. Fractional weights are truncated on the way in, so a hypergraph with weights below 1 gets zero volume.