OSLOM graph clustering algorithm
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.
Requirements
- C++ 17
- Python 3
- scikit-learn>=0.24
- pybind11>=2.6
- networkx>=2.5
The versions are what I worked on. Lower versions may work also.
Install
Install pybind11 first because there is no binary release in pip repo and the setup.py depends on pybind11.
pip install "pybind11>=2.6"
On Windows install Microsoft Visual C++ Build Tool first (refer to https://wiki.python.org/moin/WindowsCompilers).
build from source
git clone https://bochen0909@github.com/bochen0909/pyoslom.git && cd pyoslom && python setup.py 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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pyoslom-0.1.3.tar.gz
.
File metadata
- Download URL: pyoslom-0.1.3.tar.gz
- Upload date:
- Size: 253.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39d443fc8e4277d92cc7c414a3be73627528d9744895240e17ee4ae4ddcaf933 |
|
MD5 | b55683896f2940fab57050e47e6e7649 |
|
BLAKE2b-256 | a05954f2925eb4c3c6484933a1aa61ee5d694152becb890d82dac769d4079388 |