From 04fb8489c32d49469fd11df2feb9695ff6e2c5e6 Mon Sep 17 00:00:00 2001 From: Giulio Rossetti Date: Fri, 15 Oct 2021 09:42:29 +0200 Subject: [PATCH] :arrow_up: support for python-infomap>=1.7.1 --- cdlib/algorithms/bipartite_clustering.py | 6 +++++- cdlib/algorithms/crisp_partition.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cdlib/algorithms/bipartite_clustering.py b/cdlib/algorithms/bipartite_clustering.py index e43e803e..0370381f 100644 --- a/cdlib/algorithms/bipartite_clustering.py +++ b/cdlib/algorithms/bipartite_clustering.py @@ -231,7 +231,11 @@ def infomap_bipartite(g_original: object, flags: str = "") -> BiNodeClustering: im = imp.Infomap(flags) im.bipartite_start_id = min(Y.keys()) - im.add_nodes(g1.nodes) + if int(imp.__version__.replace(".", "")) >= 171: + n_dict = {i: str(n) for i, n in enumerate(g1.nodes)} + im.add_nodes(n_dict) + else: + im.add_nodes(g1.nodes) for source, target, data in g1.edges(data=True): if "weight" in data: diff --git a/cdlib/algorithms/crisp_partition.py b/cdlib/algorithms/crisp_partition.py index cdd7c661..e454cbe6 100644 --- a/cdlib/algorithms/crisp_partition.py +++ b/cdlib/algorithms/crisp_partition.py @@ -1071,7 +1071,11 @@ def infomap(g_original: object, flags: str = "") -> NodeClustering: with pipes(): im = imp.Infomap(flags) - im.add_nodes(g1.nodes) + if int(imp.__version__.replace(".", "")) >= 171: + n_dict = {i: str(n) for i, n in enumerate(g1.nodes)} + im.add_nodes(n_dict) + else: + im.add_nodes(g1.nodes) for source, target, data in g1.edges(data=True): if "weight" in data: