diff --git a/cdlib/test/test_community_discovery_models.py b/cdlib/test/test_community_discovery_models.py index 82442705..956aaf71 100644 --- a/cdlib/test/test_community_discovery_models.py +++ b/cdlib/test/test_community_discovery_models.py @@ -54,6 +54,11 @@ except ModuleNotFoundError: by = None +try: + import markov_clustering as mc +except ModuleNotFoundError: + mc = None + try: from cdlib.algorithms.internal.LPAM import LPAM except ModuleNotFoundError: @@ -354,23 +359,25 @@ def test_osse(self): self.assertEqual(type(communities.communities[0][0]), str) def test_markov_clustering(self): - g = get_string_graph() - communities = algorithms.markov_clustering(g) - self.assertEqual(type(communities.communities), list) - if len(communities.communities) > 0: - self.assertEqual(type(communities.communities[0]), list) - if len(communities.communities[0]) > 0: - self.assertEqual(type(communities.communities[0][0]), str) + if mc is not None: + g = get_string_graph() - g = nx.karate_club_graph() + communities = algorithms.markov_clustering(g) + self.assertEqual(type(communities.communities), list) + if len(communities.communities) > 0: + self.assertEqual(type(communities.communities[0]), list) + if len(communities.communities[0]) > 0: + self.assertEqual(type(communities.communities[0][0]), str) - communities = algorithms.markov_clustering(g) - self.assertEqual(type(communities.communities), list) - if len(communities.communities) > 0: - self.assertEqual(type(communities.communities[0]), list) - if len(communities.communities[0]) > 0: - self.assertEqual(type(communities.communities[0][0]), int) + g = nx.karate_club_graph() + + communities = algorithms.markov_clustering(g) + self.assertEqual(type(communities.communities), list) + if len(communities.communities) > 0: + self.assertEqual(type(communities.communities[0]), list) + if len(communities.communities[0]) > 0: + self.assertEqual(type(communities.communities[0][0]), int) # def test_bigClam(self): # if karateclub is None: