From d081b2e648a1446d7c5d4ffb876b3d2c4292d2da Mon Sep 17 00:00:00 2001 From: GiulioRossetti Date: Wed, 30 Aug 2023 16:22:13 +0200 Subject: [PATCH] :memo: documentation fix --- cdlib/algorithms/bipartite_clustering.py | 6 +++--- cdlib/algorithms/crisp_partition.py | 8 ++++---- cdlib/algorithms/internal/pycondor.py | 1 - cdlib/test/test_community_discovery_models.py | 8 ++++---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cdlib/algorithms/bipartite_clustering.py b/cdlib/algorithms/bipartite_clustering.py index 470c7d3a..45b9f88f 100644 --- a/cdlib/algorithms/bipartite_clustering.py +++ b/cdlib/algorithms/bipartite_clustering.py @@ -60,7 +60,7 @@ def bimlpa(g_original: object, theta: float = 0.3, lambd: int = 7) -> BiNodeClus >>> from cdlib import algorithms >>> import networkx as nx - >>> G = nx.algorithms.bipartite.generators.random_graph(100, 20, 0.1) + >>> G = nx.algorithms.bipartite.random_graph(50, 50, 0.25) >>> coms = algorithms.bimlpa(G) :References: @@ -288,7 +288,7 @@ def condor(g_original: object) -> BiNodeClustering: ========== ======== ======== ========= Undirected Directed Weighted Bipartite ========== ======== ======== ========= - Yes No No Yes + Yes No Yes Yes ========== ======== ======== ========= :param g_original: a networkx/igraph object @@ -298,7 +298,7 @@ def condor(g_original: object) -> BiNodeClustering: >>> from cdlib import algorithms >>> import networkx as nx - >>> G = nx.karate_club_graph() + >>> G = nx.algorithms.bipartite.random_graph(50, 50, 0.25) >>> coms = algorithms.condor(G) :References: diff --git a/cdlib/algorithms/crisp_partition.py b/cdlib/algorithms/crisp_partition.py index f1abc6f1..7a20f007 100644 --- a/cdlib/algorithms/crisp_partition.py +++ b/cdlib/algorithms/crisp_partition.py @@ -2752,7 +2752,7 @@ def ricci_community( def spectral( g_original: object, - kmax: int, + kmax: int = 2, projection_on_smaller_class: bool = True, scaler: Callable = None, ) -> NodeClustering: @@ -2768,11 +2768,11 @@ def spectral( ========== ======== ======== ========= Undirected Directed Weighted Bipartite ========== ======== ======== ========= - Yes No No Yes + Yes No No No ========== ======== ======== ========= :param g_original: a networkx/igraph object - :param kmax: maximum number of desired communities + :param kmax: maximum number of desired communities (mandatory). Default 2. :param projection_on_smaller_class: a boolean value that if True then it project a bipartite network in the smallest class of node. (default is True) :param scaler: the function to scale the fielder’s vector to apply KMeans :return: NodeClustering object @@ -2783,7 +2783,7 @@ def spectral( >>> from cdlib import algorithms >>> import networkx as nx >>> G = nx.karate_club_graph() - >>> coms = algorithms.spectral(G) + >>> coms = algorithms.spectral(G, kmax=2) :References: diff --git a/cdlib/algorithms/internal/pycondor.py b/cdlib/algorithms/internal/pycondor.py index 2e1ded25..992394f4 100644 --- a/cdlib/algorithms/internal/pycondor.py +++ b/cdlib/algorithms/internal/pycondor.py @@ -7,7 +7,6 @@ raise("This module requires the igraph package. Please install it with pip install python-igraph.") - def condor_object(net): """Initialization of the condor object. The function gets a network in edgelist format encoded in a pandas dataframe. Returns a dictionary with an igraph network, names of the targets and regulators, list of edges, diff --git a/cdlib/test/test_community_discovery_models.py b/cdlib/test/test_community_discovery_models.py index c7b828e3..9e92cfc7 100644 --- a/cdlib/test/test_community_discovery_models.py +++ b/cdlib/test/test_community_discovery_models.py @@ -653,9 +653,9 @@ def test_belief(self): self.assertEqual(type(communities.communities[0][0]), int) def test_CPM_Bipartite(self): - g = ig.Graph.Erdos_Renyi(n=80, m=600) - g.vs["type"] = 0 - g.vs[15:]["type"] = 1 + + g = nx.algorithms.bipartite.random_graph(50, 50, 0.25) + if leidenalg is None: return coms = algorithms.CPM_Bipartite(g, 0.3) @@ -909,7 +909,7 @@ def test_endntm(self): def test_scd(self): G = nx.karate_club_graph() - coms = algorithms.spectral(G, kmax=4) + coms = algorithms.spectral(G, kmax=2) self.assertEqual(type(coms.communities), list) if len(coms.communities) > 0: self.assertEqual(type(coms.communities[0]), list)