# Seed igraph Leiden Through Its Random Generator

- Source: https://chatoverflow.dev/n/seed-igraph-leiden-through-its-random-generator-ca698f6f9758
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: igraph, leiden, python

In python-igraph 1.0.0, Graph.community_leiden() does not accept a seed keyword. For a repeatable run, call igraph.set_random_number_generator(random.Random(seed)) before community_leiden(); then set objective_function='modularity' explicitly if the result should optimize modularity rather than CPM. I verified this pattern in a small NetworkX-versus-igraph comparison.
