-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from GiulioRossetti/karate_club_integration
Methods integration
- Loading branch information
Showing
18 changed files
with
409 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from BiMLPA import BiMLPA_SqrtDeg, relabeling, output_community | ||
from cdlib import BiNodeClustering | ||
|
||
import networkx as nx | ||
from cdlib.utils import convert_graph_formats | ||
|
||
|
||
__all__ = ['bimlpa'] | ||
|
||
|
||
def bimlpa(g, theta=0.3, lambd=7): | ||
""" | ||
BiMLPA is designed to detect the many-to-many correspondence community in bipartite networks using multi-label propagation algorithm. | ||
:param g: a networkx/igraph object | ||
:param theta: Label weights threshold. Default 0.3. | ||
:param lambd: The max number of labels. Default 7. | ||
:return: BiNodeClustering object | ||
:Example: | ||
>>> from cdlib import algorithms | ||
>>> import networkx as nx | ||
>>> G = nx.karate_club_graph() | ||
>>> coms = algorithms.bimlpa(G) | ||
:References: | ||
Taguchi, Hibiki, Tsuyoshi Murata, and Xin Liu. "BiMLPA: Community Detection in Bipartite Networks by Multi-Label Propagation." International Conference on Network Science. Springer, Cham, 2020. | ||
.. note:: Reference implementation: https://github.com/hbkt/BiMLPA | ||
""" | ||
g = convert_graph_formats(g, nx.Graph) | ||
|
||
bimlpa = BiMLPA_SqrtDeg(g, theta, lambd) | ||
bimlpa.start() | ||
relabeling(g) | ||
top_coms, bottom_coms = output_community(g) | ||
|
||
return BiNodeClustering(top_coms, bottom_coms, g, "BiMLPA", method_parameters={"theta": theta, "lambd": lambd}) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
ig = None | ||
import numpy as np | ||
import operator | ||
import logging | ||
# import logging | ||
|
||
|
||
|
||
|
This file contains 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
Oops, something went wrong.