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.1
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.1.tar.gz | 556.6 kB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pymocd-6.0.1-cp313-cp313-win_amd64.whl | CPython 3.13 | CPython 3.13 | Windows x86-64 | Details |
| pymocd-6.0.1-cp313-cp313-manylinux_2_34_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.34+ x86-64 | Details |
| pymocd-6.0.1-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
| pymocd-6.0.1-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details |
| pymocd-6.0.1-cp312-cp312-manylinux_2_34_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.34+ x86-64 | Details |
| pymocd-6.0.1-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| pymocd-6.0.1-cp311-cp311-win_amd64.whl | CPython 3.11 | CPython 3.11 | Windows x86-64 | Details |
| pymocd-6.0.1-cp311-cp311-manylinux_2_34_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.34+ x86-64 | Details |
| pymocd-6.0.1-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
| pymocd-6.0.1-cp310-cp310-win_amd64.whl | CPython 3.10 | CPython 3.10 | Windows x86-64 | Details |
| pymocd-6.0.1-cp310-cp310-manylinux_2_34_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.34+ x86-64 | Details |
| pymocd-6.0.1-cp310-cp310-macosx_11_0_arm64.whl | CPython 3.10 | CPython 3.10 | macOS 11.0+ ARM64 | Details |
Total release size: 9.0 MB
Release files / pymocd-6.0.1.tar.gz
| Download URL | pymocd-6.0.1.tar.gz |
|---|---|
| Size | 556.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca55eb5fea3320696a4b61bb761dd5b8dc0a7206cf617e76fce845ab92c26c19
|
|
BLAKE2b-256 checksum How to use checksums |
4035bad4b5bdee20e3acf6995c1e232099f7a9af1fa8ce255ddd1f1ae65b540e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp313-cp313-win_amd64.whl
| Download URL | pymocd-6.0.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 652.4 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ab37844f59f212ba495e1d4da260842703d5e64b3c8d13f4e7815d7b6b180dad
|
|
BLAKE2b-256 checksum How to use checksums |
e43d225b516dc357b4ab57e28031035c8e11f2ed00b9215c0cc4a42f49b6d4e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | pymocd-6.0.1-cp313-cp313-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 761.4 kB |
| Tags | CPython 3.13 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
29fa6fa5cb4b2ad1085aa63ffa34132a67acb5f2b38ce8a45bde86076339520f
|
|
BLAKE2b-256 checksum How to use checksums |
bb3ac6d3a8b84e1cc5724ee9ce5aadda4a2d0bd4074d90ea4bdd0acfc78d269e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | pymocd-6.0.1-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 680.9 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
58eb3adcd5c72e6ecc67a2f5d0f7ff046b729422290fdd4952e70727195fb605
|
|
BLAKE2b-256 checksum How to use checksums |
51612dfaee6ea3de1c0271644681baa33b2aa0d088d65f2f1b21e09458ca09e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp312-cp312-win_amd64.whl
| Download URL | pymocd-6.0.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 654.5 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
890f4a0fa6bccf1a08487e680aa1c103c4d1ac5740150e46bab31c4fb847c523
|
|
BLAKE2b-256 checksum How to use checksums |
0276e8b4b393c8f581f3042cfb8774589335cef247c6bef2ac020a9292514133
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | pymocd-6.0.1-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 761.4 kB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
535ff31eb0718cd722f43277cfe6836d8a41bb06706220611ca682f182271a90
|
|
BLAKE2b-256 checksum How to use checksums |
e7eee999b6367b18c35d8baa9b4c6f2672d7ad875925df3c87eb32e3a10e1d44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | pymocd-6.0.1-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 679.2 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e6595c965353a9248de05734885264c7b5e2363aa7ff5473d4088763f32fa1e0
|
|
BLAKE2b-256 checksum How to use checksums |
5ecb4a1bfa7d74c78f01b38cea626dfd2c9277636c0141214eb64e0acc43df60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp311-cp311-win_amd64.whl
| Download URL | pymocd-6.0.1-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 656.5 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c3a126a1abfdf97088a0680668768eeaf5af42b02c9e78fabddd517fae9525ac
|
|
BLAKE2b-256 checksum How to use checksums |
25178ea8fb5be37d6deb07264431e1777297342f3ef904707f87d3f99676b61b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp311-cp311-manylinux_2_34_x86_64.whl
| Download URL | pymocd-6.0.1-cp311-cp311-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 763.8 kB |
| Tags | CPython 3.11 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
78d2216c8e5566201817b31aff5614ed2caff2b1cd3f3f0ec1ddd548d57a5901
|
|
BLAKE2b-256 checksum How to use checksums |
5cfb09a1f9eb217e1d6b6a1f2e15f6fde3f91365a37a00ed8b29c99479be1e38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | pymocd-6.0.1-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 683.4 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ed3edaa855702be6ee634e263346d7604279fdb35429e46e9aab5306907e319a
|
|
BLAKE2b-256 checksum How to use checksums |
ad83569a34ae4dc98431300bda8fb5f78ed49b8b2ff7b5f753f09afc3e83ed83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp310-cp310-win_amd64.whl
| Download URL | pymocd-6.0.1-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 657.7 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
09b56691633219c7e832a91f9788a86f878a45214fb0b97d757f2ac2242b9857
|
|
BLAKE2b-256 checksum How to use checksums |
5865b18a69abf1a33a3c407e2b2818ab4562de99a0307660c20dd466a53c7eb5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp310-cp310-manylinux_2_34_x86_64.whl
| Download URL | pymocd-6.0.1-cp310-cp310-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 762.0 kB |
| Tags | CPython 3.10 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
2a1345da6c3841db86e1708985a88a04af3f7963cbfab895ac0bffb9527104d2
|
|
BLAKE2b-256 checksum How to use checksums |
ec251340ed4f543003bf4576e0fbad693b21c4de8ca3e0d1ddbf37038ffc4e53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / pymocd-6.0.1-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | pymocd-6.0.1-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 682.4 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
04af4eaf0ca2a7594d2b8b26bf25dfe25a80dfc1ef6da5bd6a88c9ce35d28608
|
|
BLAKE2b-256 checksum How to use checksums |
0a685d0299c6e2bd592adc9d33c528e4bede34ab8eeeac6f51e0181d68076f47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Security for pymocd 6.0.1
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.