Repository navigation
add (alpha, beta)-core computation for bipartite graphs - #7728
ShunyangLi wants to merge 4 commits into
Conversation
rossbar
left a comment
There was a problem hiding this comment.
I will start by saying that I'm certainly no expert in bipartite network analysis, so my opinions are only weakly informed.
That said, this is a simple enough operation that I'm hesitant to expand the API surface for it. I think it essentially boils down to a one-or-two liner (see inline comments) which is straightforward to formulate. Furthermore, it's easy to see how the pattern could be generalized to multipartite graphs - and in that case I don't think we'd want to have functions for each level of partitioning (e.g. an alpha_beta_gamma_core, alpha_beta_gamma_delta_core... etc.)
Given these considerations, unless this is very common operation in bipartite analysis, I'd be more inclined to include it as a gallery example than adding to the API. Just my two cents - can't wait to hear what others think!
| while True: | ||
| remove_nodes = set() | ||
|
|
||
| for u in U: | ||
| if u in G_tmp and G_tmp.degree(u) < alpha: | ||
| remove_nodes.add(u) | ||
|
|
||
| for v in V: | ||
| if v in G_tmp and G_tmp.degree(v) < beta: | ||
| remove_nodes.add(v) | ||
|
|
||
| if not remove_nodes: | ||
| break | ||
|
|
||
| G_tmp.remove_nodes_from(remove_nodes) | ||
|
|
There was a problem hiding this comment.
Ultimately I think this is a one-liner (almost):
| while True: | |
| remove_nodes = set() | |
| for u in U: | |
| if u in G_tmp and G_tmp.degree(u) < alpha: | |
| remove_nodes.add(u) | |
| for v in V: | |
| if v in G_tmp and G_tmp.degree(v) < beta: | |
| remove_nodes.add(v) | |
| if not remove_nodes: | |
| break | |
| G_tmp.remove_nodes_from(remove_nodes) | |
| while (remove_nodes := [ | |
| n for n, d in G_tmp.degree() if ((n in U and d < alpha) or (n in V and d < beta)) | |
| ]): | |
| G_tmp.remove_nodes_from(remove_nodes) |
There was a problem hiding this comment.
Thank you for your insightful feedback! I agree that since the (alpha, beta)-core is simple to implement in a few lines of code, it would be more appropriate to include it as a gallery example rather than expanding the API.
There was a problem hiding this comment.
Additionally, there are other potentially useful bipartite graph APIs, such as butterfly counting (Sanei-Mehri et al., 2018), which I can propose in future PRs to enhance the functionality for bipartite network analysis.
There was a problem hiding this comment.
it would be more appropriate to include it as a gallery example rather than expanding the API.
👍 - are you planning to do so in this PR? Please feel free; otherwise let's go ahead and close this!
Additionally, there are other potentially useful bipartite graph APIs, such as butterfly counting (Sanei-Mehri et al., 2018), which I can propose in future PRs to enhance the functionality for bipartite network analysis.
I'd recommend taking a look at the contributor guide - there is no hard-and-fast policy for inclusion, but one thing to consider is the tradeoff between the complexity of the implementation, and how "central" or widely-used the operation is in network analysis.
There was a problem hiding this comment.
Currently this algorithm is not used much, the butterfly counting may also be more suitable as an example to add to the document.
Thank you for your feedback and suggestions.
Meanwhile, I would like to ask if we have considered using the GPU to accelerate graph algorithms, because I am currently doing research on gpu-accelerated graph computation.
BTW, the PR can be closed.
There was a problem hiding this comment.
Meanwhile, I would like to ask if we have considered using the GPU to accelerate graph algorithms, because I am currently doing research on gpu-accelerated graph computation.
NetworkX itself does not support GPUs, though there is a dispatching mechanism in place to allow for different computational backends (including GPU support via cugraph) to "plug-in" to networkx functions. I'd suggest reading up on backends to learn more!
|
Thanks @ShunyangLi - I'll go ahead and close this then. Generally I think the idea is really cool, so I went ahead and opened a PR converting this to a gallery example in #7757 (and listed you as a co-author, since this is your idea!). If you're interested in adding other bipartite motifs, please feel free to use #7757 as a template/example for doing so! |
|
Hi rossbar, Thanks so much, I will add the motif counting algorithms later. |
The (alpha, beta)-core of a bipartite graph is a maximal subgraph where each vertex in the upper set has at least
alphaneighbors and each vertex in the lower set has at leastbetaneighbors.The idea is mentioned in the paper:
Efficient (alpha, beta)-core computation: An index-based approach
B. Liu, L. Yuan, X. Lin, L. Qin, W. Zhang, & J. Zhou
The World Wide Web Conference, 2019, pp. 1130-1141.
https://doi.org/10.1145/3308558.3313682