Skip to main content

Python Wrapper for OSLOM

Project description

Python binding for OSLOM graph clustering algorithm

Summary

Pyolsom is a python binding for OSLOM (Order Statistics Local Optimization Method) graph clustering algorithm.

It works with directed/undirected weighted and unweighted graph. The algorithm performs usually good but slow, so it is better to be applied to medium graph size.

The orginal C++ code is really hard to be refactored. I tried the best to make it work with python.

Known issues

  • The lib is not thread safe. So use mutliprocess when parallel is required.
  • Only works on Linux

Requirements

  • C++ 17
  • Python >= 3.10
  • scikit-learn>=0.24
  • pybind11>=2.6
  • networkx>=2.5

The versions are what I worked on. Lower versions may work also.

Install

Use setup.py

git clone https://bochen0909@github.com/bochen0909/pyoslom.git
cd pyoslom 
pip install -r requirements.txt
python setup.py install

Use Poetry

git clone https://bochen0909@github.com/bochen0909/pyoslom.git
cd pyoslom 
poetry install --no-root
poetry build
poetry install

or use pip

pip install pyoslom

How to use

Example:

import networkx as nx
from pyoslom import OSLOM

G = nx.read_pajek("example.pajek") # networkx graph or adjacency matrix
alg = OSLOM(random_state=123)
results = alg.fit_transform(G)

def print_clus(clus):
    for k, v in clus.items():
        if k != 'clusters':
            print(str(k) + "=" + str(v))
    for k, l in clus['clusters'].items():
        print("Level:" + str(k) + ", #clu=" + str(len(l)))

print_clus(results)

For more complete examples please see the notebook example.ipynb.

example_clu0.png example_clu1.png

License

The original c++ code is published at OSLOM following a research publication. However there is no license attached with it. The python wrapping work is licensed under the GPLv2.

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

pyoslom-0.1.5.tar.gz (258.1 kB view details)

Uploaded Source

Built Distributions

pyoslom-0.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pyoslom-0.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pyoslom-0.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

File details

Details for the file pyoslom-0.1.5.tar.gz.

File metadata

  • Download URL: pyoslom-0.1.5.tar.gz
  • Upload date:
  • Size: 258.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.4

File hashes

Hashes for pyoslom-0.1.5.tar.gz
Algorithm Hash digest
SHA256 129266483b5032ed995291126c92a207060c8d0cfb05f823c3e456280923f126
MD5 921afebfa718d18ef63b6d81f72af833
BLAKE2b-256 43dc53a2aa423ff3b810276d58542cd0c6664741c615acede8f4d840d68d00ba

See more details on using hashes here.

File details

Details for the file pyoslom-0.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoslom-0.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54aec706f881bb3fce4ef8725e05748cf851bdf617943551464e84a9d700ec00
MD5 1e729e0b237ebe52a8e2916e2bc8f4db
BLAKE2b-256 92ccb9e55df9ae1d2f43f525ba9c60421a90a159b23e4484a298b4a27429b625

See more details on using hashes here.

File details

Details for the file pyoslom-0.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoslom-0.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cec99ae646b63344f4fd6c3e508d5edd98f5067d9d98dd4dec129b1f015aa683
MD5 daaa9819a9482afeaed384bab7d26075
BLAKE2b-256 7419eaf1deed76b60af4af371aa7ba632927b936036d74b7a6e82b629338f8da

See more details on using hashes here.

File details

Details for the file pyoslom-0.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyoslom-0.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8a1c723c2ac0583f906893a4ce8a542d118335ce3ab6eee0c1c099a2d7513031
MD5 dbb492364a6a5fc16277ee35aab4c7ec
BLAKE2b-256 52ec9260e28f49832ec3ab0a119146231454a128ebecd3034c86ee495c2c94b1

See more details on using hashes here.

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