-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add stochastic Kronecker graph model to networkx.generators #1031
base: main
Are you sure you want to change the base?
Conversation
One quick comment: We try, as much as possible, to keep line widths less than 80 characters. So maybe try to reformat some of the docstrings to stay within this (soft) boundary. |
It's been a while since I've read this paper. Isn't the definition provided the Stochastic Kronecker Graph? Having both might be nice, even if the Kronecker graph function was just a wrapper around the stochastic version. The deterministic version might instead take an initiator graph as in the original paper, which the adjacency matrix could be drawn from. |
networkx/generators/random_graphs.py
Outdated
|
||
Parameters | ||
---------- | ||
mtx : square matrix of floats |
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.
Maybe use P
to be consistent with the notation in the paper.
@bjedwards Should be straightforward to add that. Where should it go? |
That is a good question. It might be a good idea to put a new sub-module in the |
Since no one has answered in a few days, I'll make a suggestions and see how it goes over. I would create a new file |
@bjedwards proposal is good. I agree that we could just include the "fast" version if that makes sense. (The "slow" gnp generator is indeed included for reference (and historical) value.) |
The "fast" and "slow" versions are not identical. If we compare their runs when generating a directed graph with inputs P [n-by-n matrix] and k:
I'm not sure how useful it would be to use "fast" as a replacement for "slow." The set of graphs that could be generated by "fast" is almost always a proper subset of those that could be generated by "slow." It also does not seem to generalize as well to undirected graphs (there is no analogue to the F=S^k formula in the undirected case, so currently my workaround is generating a directed graph from P and converting it to an undirected graph afterwards). The only real advantage to using "fast" is the O(F) runtime. Because of this, I think that it would make sense to either include just the "slow" implementation (which can generate the full space of possible graphs) or both "slow" and "fast". I think there might be problems if "fast" were the only Kronecker generator available. It may also be that using the name |
@bjedwards I'll go ahead then and move these to a separate |
@nadesai Thanks for the info on the difference. I see now, it is sort of like difference between |
This refactoring has been (belatedly) done. |
The code as it stands does not currently work with NumPy matrices; this seems to be the standard for all matrix types, so I will switch to working with those. There exists a function ( |
Add a new nx.generators.product module containing random graph generator algorithms based on graph products. To begin with, contains implementation of stochastic Kronecker model (described in Leskovec et al., https://arxiv.org/abs/0812.4905).
I've added two simple implementations - one O(V^2) and one "fast" O(E) - of the stochastic Kronecker graph generation model (described in "Kronecker graphs: an approach to modeling networks" by Leskovec et al.) to random_graphs.py. I also added some tests of these generators.
This is my first pull request to NetworkX, so I'm probably doing something wrong - please let me know what I should change or add.