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.

Source Distribution

slmpy-0.3.3.tar.gz (12.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page