Skip to main content

Smart local moving (SLM) community detection in Python/C++

Project description

Smart local moving (SLM) community detection in Python/C++, modeled on the Java version on https://github.com/mneedham/slm.

from slmpy import ModularityOptimzer

edges = [
         [0, 1],
         [0, 2],
         [0, 3],
         [1, 2],
         [1, 3],
         [2, 3],
         [3, 4],
         [4, 5],
         [4, 6],
         [5, 6],
         [7, 8],
        ]

mo = ModularityOptimzer(edges)
mo.fixed_nodes = [0, 4]  # This fixes nodes 0 and 4 to be in different communities
communities = mo(algorithm='smart_local_moving')

# Check answer
assert((communities == [0, 0, 0, 0, 1, 1, 1]).all())

Project details


Download files

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

Files for slmpy, version 0.3.3
Filename, size File type Python version Upload date Hashes
Filename, size slmpy-0.3.3.tar.gz (12.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page