-
-
Notifications
You must be signed in to change notification settings - Fork 393
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
feat: igraph_joint_degree_distribution #2422
Conversation
c86cb51
to
88b73a1
Compare
Codecov Report
@@ Coverage Diff @@
## master #2422 +/- ##
==========================================
+ Coverage 83.68% 83.73% +0.04%
==========================================
Files 377 377
Lines 62137 62401 +264
==========================================
+ Hits 52001 52252 +251
- Misses 10136 10149 +13
... and 6 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
a5ec8fc
to
7c49d0c
Compare
Here's a thought: Perhaps we should generalize this to work with arbitrary integer "vertex types", which can be used in place of the degrees? Then supplying in- or out-degrees would be just one choice. |
This is now implemented as @mbojan, perhaps you have some input on this function and its naming? |
138d9eb
to
704a4a7
Compare
@szhorvat , I didn't have time to study what you did in detail but if, in principle, you take an edge list (two-column matrix), replace node ids with corresponding values of some node attribute[s] (perhaps distinct attributes for source and target nodes in a digraph) and finally aggregate it by counting the unique combinations of values then indeed it is the contact layer of the mixing matrix. Thus function name seems appropriate. |
* \param graph The input graph. | ||
* \param m The mixing matrix will be stored here. | ||
* \param from_types Vertex types for source vertices. These must be non-negative integers. | ||
* \param to_types Vertex types for target vertices. These must be non-negative integers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to have to_types
for undirected graphs? I would assume it does as each undirected edge is counted in "both" directions and the types of the vertices can then differ in both configurations, but I wonder whether it would really make a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. The matrix would be different, since the row and column counts may not be the same anymore. Is it a useful matrix? I am not sure. I would leave it as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approaches to MM of undirected graphs vary. In https://mbojan.github.io/netseg/reference/mixingm.html I count each edge once (so the sum of contact layer of MM is a proper edge count) and fold all counts to upper triangle so that lower triangle is all 0s. On the other hand https://github.com/statnet/network/blob/5fb95d2feddfd2a0fa3f234a102fe2992203c7c7/R/misc.R#L120 returns always a symmetric matrix, but then all the between-group ties are counted twice.
1dbd300
to
6f61bc7
Compare
I renamed the second function to Test for |
f9dd062
to
2509e1d
Compare
@ntamas This is now ready for review (and hopefully merging, assuming tests pass). I'd like this in the next release. |
2509e1d
to
2b8ee54
Compare
There's a small bug in the one feature I didn't test ... |
2b8ee54
to
5396b00
Compare
It's good now. |
…ector, joint_degree_distribution, joint_type_distribution
Thanks a lot! |
@ntamas Thanks! AFAIC we're good to release 0.10.8. The one thing I'd do beforehand is check on why Travis is not working, and if easy, run the Travis tests once (it's exotic hardware and old compilers, so it's good to run a test before release). |
Docs and implementation are complete, but no tests yet.
I'd like to have #2419 merged before adding tests and finalizing the cross referencing of docs.
The following is a nice visual illustration of why we need the joint degree distribution (and not joint degree matrix) for statistical applications dealing with degree correlations.
Join degree matrix of a large undirected Erdős-Rényi graph:
Joint degree distribution of the same: