diff --git a/.semversioner/next-release/patch-20240912220455353844.json b/.semversioner/next-release/patch-20240912220455353844.json new file mode 100644 index 00000000..8279dd0d --- /dev/null +++ b/.semversioner/next-release/patch-20240912220455353844.json @@ -0,0 +1,4 @@ +{ + "type": "patch", + "description": "Fix seeded random gen on clustering" +} diff --git a/graphrag/index/verbs/graph/clustering/cluster_graph.py b/graphrag/index/verbs/graph/clustering/cluster_graph.py index e8be50e8..e465917b 100644 --- a/graphrag/index/verbs/graph/clustering/cluster_graph.py +++ b/graphrag/index/verbs/graph/clustering/cluster_graph.py @@ -87,6 +87,7 @@ def cluster_graph( cast(str, row[column]), cast(Communities, row[community_map_to]), level, + seed=strategy.get("seed"), ) ) ) @@ -111,7 +112,7 @@ def cluster_graph( # TODO: This should support str | nx.Graph as a graphml param def apply_clustering( - graphml: str, communities: Communities, level=0, seed=0xF001 + graphml: str, communities: Communities, level: int = 0, seed: int | None = None ) -> nx.Graph: """Apply clustering to a graphml string.""" random = Random(seed) # noqa S311