diff --git a/cdlib/algorithms/crisp_partition.py b/cdlib/algorithms/crisp_partition.py index b9d14369..fa24a811 100644 --- a/cdlib/algorithms/crisp_partition.py +++ b/cdlib/algorithms/crisp_partition.py @@ -38,8 +38,6 @@ import warnings -import markov_clustering as mc - # from chinese_whispers import chinese_whispers as cw # from chinese_whispers import aggregate_clusters from thresholdclustering.thresholdclustering import best_partition as th_best_partition @@ -91,6 +89,13 @@ missing_packages.add("bayanpy") by = None + +try: + import markov_clustering as mc +except ModuleNotFoundError: + missing_packages.add("markov_clustering") + by = None + # try: # import karateclub # except ModuleNotFoundError: @@ -1669,6 +1674,13 @@ def markov_clustering( .. note:: Reference implementation: https://github.com/GuyAllard/markov_clustering """ + if mc is None: + raise Exception( + "===================================================== \n" + "The markov clustering algorithm seems not to be installed (or incorrectly installed). \n" + "Please resolve with: pip install markov_clustering" + ) + g = convert_graph_formats(g_original, nx.Graph) g, maps = nx_node_integer_mapping(g) diff --git a/cdlib/algorithms/internal/RSC.py b/cdlib/algorithms/internal/RSC.py index 0215300e..406f271f 100644 --- a/cdlib/algorithms/internal/RSC.py +++ b/cdlib/algorithms/internal/RSC.py @@ -34,8 +34,8 @@ def __regularized_laplacian_matrix(adj_matrix, tau): # diags will be zero at points where there is no edge and/or the node you are at # ignore the error and make it zero later - with scipy.errstate(divide="ignore"): - diags_sqrt = 1.0 / scipy.sqrt(diags) + #with scipy.errstate(divide="ignore"): + diags_sqrt = 1.0 / scipy.sqrt(diags) diags_sqrt[scipy.isinf(diags_sqrt)] = 0 D = scipy.sparse.spdiags(diags_sqrt, [0], m, n, format="csr") diff --git a/requirements.txt b/requirements.txt index 33707029..521e61c7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,6 @@ seaborn pandas eva_lcd bimlpa -markov_clustering python-igraph>=0.10 angelcommunity pooch diff --git a/requirements_optional.txt b/requirements_optional.txt index 895e0ef7..3a8309f3 100644 --- a/requirements_optional.txt +++ b/requirements_optional.txt @@ -3,4 +3,5 @@ networkit pycombo leidenalg infomap>=1.3.0 -wurlitzer>=1.0.2 \ No newline at end of file +wurlitzer>=1.0.2 +markov_clustering \ No newline at end of file