pymocd is a Python library, powered by a Rust backend, for multi-objective evolutionary community detection in complex networks. The evolutionary core is written in Rust and exposed through PyO3, giving it a large speed advantage over pure-Python implementations while staying a drop-in for the NetworkX / igraph ecosystem, making it well-suited to large-scale graphs.
Read the Documentation for detailed guidance and usage instructions.
Getting started
pip install pymocd
import networkx as nx
import pymocd
G = nx.karate_club_graph() # any NetworkX / igraph graph, integer node ids
communities = pymocd.rimpso(G) # -> dict[node, community]
Every detector returns a single crisp partition as dict[node, community].
Algorithms
pymocd exposes nine community-detection algorithms through ten
detector entry points (Shi-MOCD ships under two selection rules).
| API | Source | Objectives | Engine | Decision Making | Code |
|---|---|---|---|---|---|
rimpso |
Santos, in prep. (2026) | Constant Potts split: cut fraction + pair coverage | memetic MOPSO over a resolution ladder | best-fit assortative block model | this library |
hpmocd |
Santos et al., SNAM 2025 | decomposed modularity (intra, inter) | NSGA-II | max Q | this library |
cdrme |
Dabaghi-Zarandi et al., JNCA 2025 | Eq. 12 linkage scalar (single) | random walks + agglomerative merge | max Q | private, vendored here |
mmcomo |
Zhang et al., IEEE CIM 2023 | kernel k-means + ratio cut | macro/micro co-evolutionary NSGA-II | max Q | — |
ccm |
Shaik et al., SN Comp. Sci. 2021 | community score + fitness + modularity | NSGA-III | max Q | — |
krm |
Shaik et al., SN Comp. Sci. 2021 | kernel k-means + ratio cut + modularity | NSGA-III | max Q | — |
gdpso |
Cai et al., Inf. Sciences 2015 | Newman–Girvan modularity (single) | greedy discrete PSO | swarm best | doctor-cai/GDPSO |
mocd_q |
Shi et al., Applied Soft Computing 2012 | decomposed modularity | PESA-II | max Q | — |
mocd_d |
Shi et al., Applied Soft Computing 2012 | decomposed modularity | PESA-II | max–min random-graph distance | — |
moga_net |
Pizzuti, IEEE TEC 2012 | community score + fitness | NSGA-II | max Q | Moganet2016.zip |
Each detector has a module README with its full derivation, its parameter
table and the list of every deliberate divergence from its paper:
rimpso ·
hpmocd ·
cdrme ·
mmcomo ·
ccm ·
krm ·
gdpso ·
mocd (Shi-MOCD) ·
moganet —
index.
Usage
import pymocd
# This library's own detectors
part = pymocd.rimpso(G) # RIMPSO (recommended default)
part = pymocd.hpmocd(G) # HP-MOCD
# Re-implemented baselines
part = pymocd.cdrme(G) # CDRME (Dabaghi-Zarandi et al.)
part = pymocd.mmcomo(G) # MMCoMO (Zhang et al.)
part = pymocd.ccm(G) # CCM (Shaik et al., NSGA-III)
part = pymocd.krm(G) # KRM (Shaik et al., NSGA-III)
part = pymocd.gdpso(G) # GDPSO (Cai et al., particle swarm)
part = pymocd.mocd_q(G) # Shi-MOCD, max-modularity selection
part = pymocd.mocd_d(G) # Shi-MOCD, max-min-distance selection
part = pymocd.moga_net(G) # MOGA-Net (Pizzuti)
# All return dict[node, community]; isolated nodes -> -1
Every detector except hpmocd takes its budget as keyword arguments. The
values below are the shipped defaults, which follow each paper wherever the
paper states them:
pymocd.rimpso(G, pop_size=100, num_gens=100, inertia=0.4, cognitive=0.7, social=0.7,
local_rate=0.35, archive=100, ls_period=10, seed=0)
pymocd.mmcomo(G, pop_size=100, num_gens=50, cross_rate=0.1, mut_rate=0.1, gap=10, beta=0.05)
pymocd.ccm(G, pop_size=200, num_gens=100, cross_rate=0.8, mut_rate=1/68, r=1.0, alpha=1.0, divisions=12)
pymocd.krm(G, pop_size=100, num_gens=100, cross_rate=0.8, mut_rate=1/34, divisions=12)
pymocd.moga_net(G, pop_size=300, num_gens=30, cross_rate=0.8, mut_rate=0.2, r=2.0, alpha=1.0)
pymocd.gdpso(G, pop_size=100, num_gens=250, w=0.7298, c1=1.4961, c2=1.4961,
mut_rate=0.1, mut_frac=0.1, lpa_sweeps=5)
pymocd.cdrme(G, alpha_walk=1.0, n_walk=50, pop_size=300, elite_size=300,
alpha_mut=0.5, mut_sweeps=10)
pymocd.mocd_q(G, pop_size=100, num_gens=100, cross_rate=0.9, mut_rate=0.1)
pymocd.mocd_d(G, pop_size=100, num_gens=100, cross_rate=0.9, mut_rate=0.1, rand_networks=3)
The one exception is Shi-MOCD: mocd_q and mocd_d default to this repo's
HP-MOCD-parity benchmark budget, not Shi's published configuration, which
is cross_rate=0.6, mut_rate=0.4 with per-graph population and generation
counts from the paper's Table 1. Pass those explicitly to reproduce the paper.
hpmocd(G) takes the graph only and runs at its published configuration; for
a tunable HP-MOCD, or to plug in your own Python objective functions, use the
pymocd.HpMocd class instead.
Pareto fronts
Seven of the eleven entry points expose the candidate set their selection rule picks from:
fronts = pymocd.rimpso_fronts(G) # list[dict[node, community]]
fronts = pymocd.hpmocd_fronts(G)
fronts = pymocd.mmcomo_fronts(G)
fronts = pymocd.ccm_fronts(G)
fronts = pymocd.krm_fronts(G)
fronts = pymocd.moga_net_fronts(G)
# RIMPSO only: run its label-free selection rule over partitions produced
# elsewhere, which separates the search's contribution from the selector's
pick, points = pymocd.rimpso_select(G, candidates)
Those are exactly the detectors with a front accessor. gdpso and cdrme
are single-objective, and mocd_q / mocd_d do not expose theirs, so there is
no gdpso_fronts, cdrme_fronts or mocd_fronts.
pymocd.mr_mocd, pymocd.mr_mocd_fronts and pymocd.mr_mocd_select are the
names this detector carried before it was renamed to RIMPSO; pymocd.scale and
pymocd.scale_fronts are older still. All five are deprecated aliases for the
same function objects as rimpso, rimpso_fronts and rimpso_select, kept so
pinned callers keep working. They emit no warning and do not appear in the type
stubs. Use the new names.
Helpers
pymocd.max_cores(8) # set Rayon thread pool (first call wins)
# Fast native ground-truth agreement metrics between two {node: community}
# dicts, computed over their shared nodes
nmi, ami, ari, f1 = pymocd.gt_metrics(partition, gt)
pymocd.nmi(partition, gt) # or each metric individually
pymocd.ami(partition, gt)
pymocd.ari(partition, gt)
pymocd.f1(partition, gt) # pairwise F1
Contributing
Contributions are welcome, open an issue or a pull request for features, bug fixes, or improvements. This project is licensed under GPL-3.0 or later.
Citation
If you use any algorithm in your research, please cite:
@article{Santos2025,
author = {Santos, Guilherme O. and Vieira, Lucas S. and Rossetti, Giulio and Ferreira, Carlos H. G. and Moreira, Gladston J. P.},
title = {A high-performance evolutionary multiobjective community detection algorithm},
journal = {Social Network Analysis and Mining},
year = {2025},
volume = {15},
number = {1},
pages = {110},
doi = {10.1007/s13278-025-01519-7},
url = {https://doi.org/10.1007/s13278-025-01519-7},
issn = {1869-5469},
date = {2025-11-18}
}
Metadata
Release files for pymocd 6.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pymocd-6.0.0.tar.gz | 556.6 kB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pymocd-6.0.0-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| pymocd-6.0.0-cp313-cp313-manylinux_2_34_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.34+ x86-64 | Details |
| pymocd-6.0.0-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
| pymocd-6.0.0-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| pymocd-6.0.0-cp312-cp312-manylinux_2_34_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.34+ x86-64 | Details |
| pymocd-6.0.0-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| pymocd-6.0.0-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| pymocd-6.0.0-cp311-cp311-manylinux_2_34_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.34+ x86-64 | Details |
| pymocd-6.0.0-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
| pymocd-6.0.0-cp310-cp310-win_amd64.whl | CPython 3.10 | CPython 3.10 | Windows x86-64 | Details |
| pymocd-6.0.0-cp310-cp310-manylinux_2_34_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.34+ x86-64 | Details |
| pymocd-6.0.0-cp310-cp310-macosx_11_0_arm64.whl | CPython 3.10 | CPython 3.10 | macOS 11.0+ ARM64 | Details |
Total release size: 8.9 MB
Release files / pymocd-6.0.0.tar.gz
| Download URL | pymocd-6.0.0.tar.gz |
|---|---|
| Size | 556.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f672c854e89d8862c9393f7f137a9565b31930fd4df1726d610d58f06a7e2c19
|
|
BLAKE2b-256 checksum How to use checksums |
98af395e533c8a0e6e2827bc28d607c7355f806df9809858390835ff12a73dd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp313-cp313-win_amd64.whl
| Download URL | pymocd-6.0.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 645.2 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9b62460cfd095ff93d08e4cd76534685a2980a6b7738ee13b647add3bba122ae
|
|
BLAKE2b-256 checksum How to use checksums |
e00c272ea4718a7490732ab9ea099a5d11451454790cd769656f017c04b85ca6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | pymocd-6.0.0-cp313-cp313-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 758.9 kB |
| Tags | CPython 3.13 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
2ca2ab93d41f0ad17eee1314e2d8de770a6e7b111a61cff499a44c4722cec59b
|
|
BLAKE2b-256 checksum How to use checksums |
76a384bb29002f94d9cb9e52c86052481b6e17799dbf35223e51a3210500a6f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | pymocd-6.0.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 667.5 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
381416fc11378c436c61e9878cdbdf1d2935e06919ca1c63a308378aff77e6a5
|
|
BLAKE2b-256 checksum How to use checksums |
20178fe39e93cb66050f0b533c7e4cc0a714db280298e1ecfe9650456d8fb63a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp312-cp312-win_amd64.whl
| Download URL | pymocd-6.0.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 646.1 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5e81be2ac91a5b82afce68ee962864b6a1fd319335a92113edfacab3f2115ac5
|
|
BLAKE2b-256 checksum How to use checksums |
b257badb53d713363ebae0df44badf72f790c31701d67372f6d8b1990895980c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | pymocd-6.0.0-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 759.1 kB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
d1753f4d735ed311402e6bd08870a64cb2cbb9a07d786217c91410a07c1a0a2b
|
|
BLAKE2b-256 checksum How to use checksums |
290ccca467a9640716b0432742937a4a986f10e9aa626b2f22159d1764f0abe3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | pymocd-6.0.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 667.7 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
8e5eb1735375acb71214de79bc2c946c3968fcc9027a3026060139df5b50681e
|
|
BLAKE2b-256 checksum How to use checksums |
368af27f9ddad4924bb5842ddb585e6bcc3f68a62634ae01f85c7a23574b4bd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp311-cp311-win_amd64.whl
| Download URL | pymocd-6.0.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 648.7 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
effd7b5205a3cf47ae119afcadf675bcda3ef80376716745af9af858721ffaaa
|
|
BLAKE2b-256 checksum How to use checksums |
0b3a2bc45624061aa9c940d6b64e3273697b13ed208ec02be0ec430e581ae8a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp311-cp311-manylinux_2_34_x86_64.whl
| Download URL | pymocd-6.0.0-cp311-cp311-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 760.7 kB |
| Tags | CPython 3.11 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
fa7e0ee940559e14855892596fa78c72f85f44764e3973f6b01a69faa5c2883b
|
|
BLAKE2b-256 checksum How to use checksums |
2bd0bb5990069c5929e8819349eb4618c622334b75d1031641c9c9b4318edee0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | pymocd-6.0.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 674.2 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2c5a88645f013edf7fe93ebe3ad6c90bb19c4850638815a6ece41575e07902ac
|
|
BLAKE2b-256 checksum How to use checksums |
41ba332eb8e8279f776d8888c5bb1345a89084cdaf3b67c67c78f98a9408df71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp310-cp310-win_amd64.whl
| Download URL | pymocd-6.0.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 652.4 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
80a572f3321460f10472a3f99eb9f34fa646b7f14c3a11f271869eab166d3ce2
|
|
BLAKE2b-256 checksum How to use checksums |
6b978a70ca880a721ba9a296c0b092cb3172aad3c964e6a15f63f48b6e993cff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp310-cp310-manylinux_2_34_x86_64.whl
| Download URL | pymocd-6.0.0-cp310-cp310-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 761.2 kB |
| Tags | CPython 3.10 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
d4e56c630fda3fb6a6b9df159e7463fbb8a7dddcc70a74771c41b5652d6da302
|
|
BLAKE2b-256 checksum How to use checksums |
9c1885c4236fe68e7f323ebf19de28dbef13999fce97066832eb296c0964bf91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Release files / pymocd-6.0.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | pymocd-6.0.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 674.2 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fa28c16dc81fa4cf1e9e620893a5144a3db2fc92ac62f5e7f2dd65237af824f9
|
|
BLAKE2b-256 checksum How to use checksums |
3d433c73a3935eb5b82acacb101587b49995dc1e400cd8a70393e8669d560b40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.21
|
Security for pymocd 6.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.