New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: correct calculation of knn(k) in avg_nearest_neighbor_degree() #2419
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2419 +/- ##
==========================================
+ Coverage 83.67% 83.68% +0.01%
==========================================
Files 377 377
Lines 62080 62135 +55
==========================================
+ Hits 51943 51999 +56
+ Misses 10137 10136 -1
Continue to review full report in Codecov by Sentry.
|
6ad9008
to
41b7c8d
Compare
@suthers Can you have a look through the documentation of the |
d162d3c
to
b1903f1
Compare
@ntamas @vtraag This is functionally ready, please review. What's missing is expanded testing and expanded docs. We also need to settle on a final name for |
Remind me, how do we order parameters in new functions, in particular where does |
|
Why |
Looks good to me but I need some more time to validate the test case. Until then, feel free to go ahead with the documentation and other chores. Thanks! |
Just added more tests. |
@ntamas Here are the graphs, to ease validation. ugDegrees are below. Joint degree distribution: dgIn- and out-degrees are below and above. Joint out-in degree distribution: |
The name |
@vtraag I am not asking to change the name of the existing function. I am asking for feedback on the name of the new one, currently called |
Sorry, I misunderstood then! I can take an actual closer look later this week probably... |
I propose Other options:
If I don't hear back in a couple of days, I'll go ahead with the rename to |
|
@ntamas I'm not sure if you saw my question in chat. Can you create a new wiki page and write up the preferred argument order very briefly? I always get confused about this and I need some documentation I can refer to. |
@ntamas If the argument order is correct, I would like to merge this as-is, without squashing. I would like to backport the weighted knnk bugfix to the 0.9 branch, so that it can be included in the upcoming R/igraph 1.6.0, and so that we can deal with revdepcheck results soon. Any additional minor changes an be made after merging. EDIT: The force push below was to rebase on latest |
…r_degree(), fixes #183
Will do, I just need to find some spare time to do it :)
Sure, go ahead. |
Since it's already merged, I won't take a further look anymore... |
No need to take a look at the bugfix, I am confident in that. A read through of the docs, a check of the argument order, and a check of the function name would be very welcome. These can still be improved. I wanted to merge to get the bugfix in ASAP and backport it to 0.9. |
The weighted calculation of$k_{nn}(k)$ was incorrect. What the function did so far was to calculate the weighted mean neighbour degree for each node, then to average these weighted mean neighbour degrees within groups of vertices of the same degree. This does not agree with the definition, e.g. in Barrat et al:
Please see here for details:
https://igraph.discourse.group/t/replicating-4-directed-assortativities-in-the-literature-with-knn-mode/1691
CC @suthers
This PR is only draft for now, as I plan to make further changes. This one fix is ready for review.
Further changes will be:
vids
is not set to all vertices). Furthermore, @suthers makes a good argument for using a different "mode" concept when computingIf$P_{ij}$ is the joint degree distribution, then $k_{nn}(k) = \frac{\sum_{j} j P_{kj}}{\sum_{j} P_{kj}}$ . I verified that the updated function agrees with this, using an independent weighted computation of $P_{ij}$ .