Skip to content

Commit

Permalink
⬇️ markov_clustering moved to optional
Browse files Browse the repository at this point in the history
  • Loading branch information
GiulioRossetti committed May 13, 2024
1 parent 8356a8b commit bee4619
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
16 changes: 14 additions & 2 deletions cdlib/algorithms/crisp_partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions cdlib/algorithms/internal/RSC.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ seaborn
pandas
eva_lcd
bimlpa
markov_clustering
python-igraph>=0.10
angelcommunity
pooch
Expand Down
3 changes: 2 additions & 1 deletion requirements_optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ networkit
pycombo
leidenalg
infomap>=1.3.0
wurlitzer>=1.0.2
wurlitzer>=1.0.2
markov_clustering

0 comments on commit bee4619

Please sign in to comment.