Skip to main content
pymocd logo

PyPI PublishRust Compilation PyPI - Version PyPI - License

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.smocc(G)       # -> dict[node, community]

[!IMPORTANT] Graphs must be in NetworkX or igraph compatible format with integer node ids. Isolated nodes are assigned community -1.

Every detector returns a single crisp partition as dict[node, community].

Algorithms

pymocd ships eight detectors. SMOCC and HP-MOCD are the library's own contributions; the remaining six are faithful re-implementations of published baselines (the original authors released no code).

API Algorithm Objectives & engine Solution selection Year
smocc SMOCC (Santos, in prep.) heterogeneous intra/inter + KKM/ratio-cut objectives, sparse macro–micro co-evolutionary NSGA-II (near-linear, no dense kernel) label-free normalised scalarisation 2026
hpmocd HP-MOCD (Santos et al.) decomposed modularity, parallel NSGA-II max modularity Q 2025
mmcomo MMCoMO (Zhang et al.) kernel k-means + ratio cut, macro/micro co-evolutionary NSGA-II max Q (front via mmcomo_fronts) 2023
ccm CCM (Shaik et al.) score + fitness + modularity, NSGA-III max Q (front via ccm_fronts) 2021
krm KRM (Shaik et al.) kernel k-means + ratio cut + modularity, NSGA-III max Q (front via krm_fronts) 2021
mocd_q Shi-MOCD (Shi et al.) decomposed modularity, PESA-II max Q 2012
mocd_d Shi-MOCD (Shi et al.) decomposed modularity, PESA-II max-min distance to random nets 2012
moga_net MOGA-Net (Pizzuti) community score + fitness, NSGA-II max Q (front via moga_net_fronts) 2009

Usage

import pymocd

# Recommended detectors (defaults work out of the box)
part = pymocd.smocc(G)            # SMOCC
part = pymocd.hpmocd(G)           # HP-MOCD

# Baselines (sensible defaults; pop_size / num_gens / rates are tunable kwargs)
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)
part = pymocd.ccm(G)              # NSGA-III CCM (Shaik et al.)
part = pymocd.krm(G)              # NSGA-III KRM (Shaik et al.)
part = pymocd.mmcomo(G)           # MMCoMO (Zhang et al.), macro/micro co-evolution

# All return dict[node, community]; isolated nodes -> -1

The Pareto frontier of some algorithms is exposed for inspection:

fronts = pymocd.smocc_fronts(G)      # list[dict[node, community]]
fronts = pymocd.mmcomo_fronts(G)     # list[dict[node, community]]

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}
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymocd-5.1.0.tar.gz (446.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pymocd-5.1.0-cp313-cp313-win_amd64.whl (609.3 kB view details)

Uploaded CPython 3.13Windows x86-64

pymocd-5.1.0-cp313-cp313-manylinux_2_34_x86_64.whl (713.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

pymocd-5.1.0-cp313-cp313-macosx_11_0_arm64.whl (629.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pymocd-5.1.0-cp312-cp312-win_amd64.whl (610.5 kB view details)

Uploaded CPython 3.12Windows x86-64

pymocd-5.1.0-cp312-cp312-manylinux_2_34_x86_64.whl (713.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

pymocd-5.1.0-cp312-cp312-macosx_11_0_arm64.whl (631.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pymocd-5.1.0-cp311-cp311-win_amd64.whl (610.7 kB view details)

Uploaded CPython 3.11Windows x86-64

pymocd-5.1.0-cp311-cp311-manylinux_2_34_x86_64.whl (715.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

pymocd-5.1.0-cp311-cp311-macosx_11_0_arm64.whl (635.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pymocd-5.1.0-cp310-cp310-win_amd64.whl (612.0 kB view details)

Uploaded CPython 3.10Windows x86-64

pymocd-5.1.0-cp310-cp310-manylinux_2_34_x86_64.whl (714.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

pymocd-5.1.0-cp310-cp310-macosx_11_0_arm64.whl (637.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file pymocd-5.1.0.tar.gz.

File metadata

  • Download URL: pymocd-5.1.0.tar.gz
  • Upload date:
  • Size: 446.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for pymocd-5.1.0.tar.gz
Algorithm Hash digest
SHA256 d55ebca5c4e625e6fb2de2979774c8865e6ab18b5dc5b685d4c825bfc8b68ab3
MD5 9a12d6cdb8ba572a6fea5d72609dd4ba
BLAKE2b-256 524bb2a613a32ce05cde68ba6546364ab19e87ede7d18e2320542753473cd888

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pymocd-5.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 609.3 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for pymocd-5.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 05eed238bacbaa2eb3daee623b0b4927a1eb9ca9e1a130276621f0abf56c289f
MD5 cc944592f41fe766279fab9b42e21c05
BLAKE2b-256 a9a20338e483a32f38df1e543eb8d066075ceb37db9faf3d8498dd066d0fdd74

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pymocd-5.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c5f34f1558068133be0fc6cbde6b75a3bbea5757ccc71b7f7206a3fd07eea45b
MD5 17d6a5eecc93c614a794e0c4660ca6be
BLAKE2b-256 d57a3e05eae0b64a77ab49e36aea169d89ecd3b92f900ac03533c724161d8601

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymocd-5.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e9929eaeb1094ff4b675a9886526cfa5ed24132c4355b4ca8a74bf0c8b469baa
MD5 41df4053d5b3f248778d36803d49bdd1
BLAKE2b-256 5f2fb7bf43bfc5c5f4a893a7eb4186a7cd20c68d1870e74a6e8b63a6c4b478f5

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pymocd-5.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 610.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for pymocd-5.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 51911608f7366f593ff2cf8fb866871217fbcc7398f7f98f2e2c6ed103b16383
MD5 80368165f2cae26de70443f924f4faef
BLAKE2b-256 13ba365b3c72f197fd5752d1971faf91ba14dd6827634cfc0b9c0f2e7541af88

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pymocd-5.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 88d88e189938f51a834c0a63c6417e9d4835b03f7a9b52eb1d9f0d5c67e9efc8
MD5 3c8b4914565874c2810c3639bc69799c
BLAKE2b-256 fcd072039e63b7b6b0eff19ad865c1a8716c08beb7a55d9b42cb9f91014eaddd

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymocd-5.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f9f621ed5f7d1c84726bca9caba60ea958c257dc00933224c32d8d11814e499a
MD5 f7ecdec81ae2d2ff1c32c57c4eebdb8b
BLAKE2b-256 61735e5c173f8fb3af91c1206cc558cab49215c09668f531d586773c08202cc2

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pymocd-5.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 610.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for pymocd-5.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bba88b60c094841ced5fd89c36bb680b176b6f266b69768236af3a6ed51752b1
MD5 7016a71828470e99a199a5ebcfc468c6
BLAKE2b-256 04f855731c8467e2aed62b9185319128e98579212be99314dae0fa225f388f56

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pymocd-5.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 02b6fd7e8ca8a94f6b1dfba96676fd2ec79477b943e07238b1afe45116b8e279
MD5 1250cf4ee5a4016404872a4ae3e5f93e
BLAKE2b-256 154398137951c5cd80ca9cecb1236eba39b1832fedafbe80d4d5da90ade1eae2

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymocd-5.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8477bc179b88b777b8509c9be2dd69ffa9166d37d941d490a866755adfb6b5b
MD5 2688326a675b168253c2c16958f38f8d
BLAKE2b-256 7074fcc961a224bf9522394d971dca58568d77dbc6e26b3a1b0bdc1a145ae0f3

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pymocd-5.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 612.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for pymocd-5.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8921a40b5f731379ccdc5447d0a8774a91fe8f965c5d0acea086731a8b4217e5
MD5 da56bcc26a7523ac9c217bb0c5b45830
BLAKE2b-256 d1f8a7594ea13a609dc1a05b75d47cf912ab35d05952ff82eda7166513690c29

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pymocd-5.1.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 bdba88f9e841bd06ee2db69922c04e22980ea2186140790aa85460debd760075
MD5 0ef66f4fc443ba4119628c323f5f0b73
BLAKE2b-256 9d9d1925173f3079f26104724d639b783f66439ad5b889567259893727bc731e

See more details on using hashes here.

File details

Details for the file pymocd-5.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pymocd-5.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fb8254e095450783db58e7e3ac0c93932b8b27a52f434030e64e27b1df2a8b2f
MD5 64de194f42a2a57e1438902d9b8f5a70
BLAKE2b-256 56e8e525a3306a75e790e3634f7eb4cef8b71be54bae2006a7f5d151b3bf27cf

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

5.1.0 This release

13 files

5.0.1

13 files

4.0.0

13 files

3.0.0

16 files

2.0.2

16 files

2.0.0

16 files

1.5.1

16 files

1.5.0

16 files

1.3.0

16 files

1.2.5

16 files

1.1.3

16 files

1.0.3

16 files

1.0.1

16 files

1.0.0

16 files

0.2.0

16 files

0.1.0

16 files

0.0.1

16 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page