SpeakEasy2 community detection algorithm
Project description
Python SpeakEasy2 package
Provides the SpeakEasy2 community detection algorithm to cluster graph's stored as igraph's data type.
Example:
import igraph as ig
import speakeasy2 as se2
g = ig.Graph.Famous("Zachary")
memb = se2.cluster(g)
From the results, a node ordering can be computed to group nodes in a community together. This can be used as an index and works to display the community structure using a heatmap to view the adjacency matrix.
ordering = se2.order_nodes(g, memb)
SpeakEasy 2 can work with weighted graphs by either passing weights as a list with length equal to the number of edges or by using the igraph attribute table.
g.es["weight"] = [1 for _ in range(g.ecount())]
memb = se2.cluster(g)
By default, SpeakEasy 2 will check if there is an edge attribute associated with the graph named weight
and use those as weights. If you want to use a different edge attribute, pass the name of the attribute.
memb = se2.cluster(g, weights="tie_strength")
Or if a graph has a weight edge attribute but you don't want to use them, explicitly pass None
to the weights
keyword argument.
Subclustering can be used to detect hierarchical community structure.
memb = se2.cluster(g, subcluster=2)
The number determines how many levels to perform community detection at. The default 1 means only to perform community detection at the top level (i.e. no subclustering). When subclustering, membership will be a list of igraph.VertexClustering
objects, the top level membership will be the object at index 0.
A few other useful keywords arguments are max_threads
, verbose
, and seed
. The max_thread
keyword determines how many processors SpeakEasy 2 is allowed to use. By default the value returned by OpenMP is used. To prevent parallel processing, explicitly pass max_threads = 1
to the method.
The verbose
option will cause the algorithm to print out some information about the process.
For reproducible results, the seed
option sets the seed of the random number generator. Note: this is a random number generator managed by the underlying C library and is independent of other random number generators that might have been set in python.
Installation
speakeasy2 is available from pypi so it can be installed with pip
or other package managers.
pip install --user speakeasy2
Building from source
This package can be built using CMake
. It requires the flex
, bison
, and libxml2
dependencies for building igraph
and poetry
for managing python dependencies.
Since the igraph
package is supplied by the vendored SE2 C library, after cloning the source directory, submodules most be recursively initialized.
git clone "https://github.com/SpeakEasy-2/python-speakeasy2"
cd python-speakeasy2
git submodule update --init --recursive
Then build the package using cmake
:
cmake -B build
camke --build build
Since the compiled python shared libraries are built in the build
directory, to use the local python package, link the shared libs to the python package:
cd speakeasy2
ln -s ../build/_speakeasy2.so
cd ..
Use poetry
to install dependencies in a virtual env:
poetry install
It should now be possible to run scripts through poetry
:
poetry run ipython path/to/script.py
Or enter a python repository with the private environment activate in the same way.
poetry run ipython
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
Built Distributions
File details
Details for the file speakeasy2-0.1.0.tar.gz
.
File metadata
- Download URL: speakeasy2-0.1.0.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e13f8088f501b76e514d5f5d8573f6b8f90baaeb1048a2ca40c1d2d5f28dea2 |
|
MD5 | a57aa7a8dbf665b8f04a1a6a5e7dc9b5 |
|
BLAKE2b-256 | 26477f6fbff297637885115bb7bccc53178d7b045060fbe6e2f439033881d36f |
File details
Details for the file speakeasy2-0.1.0-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: speakeasy2-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 379.9 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cea4d298a6035fb8c3759693bd1fe035fbf8b84bc923ba3529e31adfe2ba8490 |
|
MD5 | ee6ac5e77bd9f773582d2be2d84113af |
|
BLAKE2b-256 | 9f49736e751904009604ebb434abd76bf773f6ffa24cd8316da5850689d7cfff |
File details
Details for the file speakeasy2-0.1.0-cp312-cp312-manylinux_2_31_x86_64.whl
.
File metadata
- Download URL: speakeasy2-0.1.0-cp312-cp312-manylinux_2_31_x86_64.whl
- Upload date:
- Size: 309.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.31+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36d0eea5959da4254a9d98052a6523005bd292552cc33e4b678ecfba01e283f9 |
|
MD5 | 2731e514719e41eb5644343cf2620a1e |
|
BLAKE2b-256 | 1693db47d3abd49e9527619d850060765c0682b4dd27607860a48a2c4317d0a9 |
File details
Details for the file speakeasy2-0.1.0-cp312-cp312-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: speakeasy2-0.1.0-cp312-cp312-macosx_12_0_x86_64.whl
- Upload date:
- Size: 283.8 kB
- Tags: CPython 3.12, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e012cfc608e29e422f2fb6a7d92c3c0314811c10808eb5f2af451726cf3b60f |
|
MD5 | 2022b5f26abcdf025e6672cb4331dc78 |
|
BLAKE2b-256 | e0f2f2a8e1ae42211b8796cfa1b4767c4b23e9dcec0e3a2cb261bc1aff0c56c8 |
File details
Details for the file speakeasy2-0.1.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: speakeasy2-0.1.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 379.9 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 739e988b189cf00ec0158e61798cf780102c42a962fae9c3b49eb11ab53d8d3e |
|
MD5 | 83f535e8e76a95ed79642b25018dfbe5 |
|
BLAKE2b-256 | 13eb9d4d1d70d6abdd771f72b3680f133ae020b643858824f0472721241e0a18 |
File details
Details for the file speakeasy2-0.1.0-cp311-cp311-manylinux_2_31_x86_64.whl
.
File metadata
- Download URL: speakeasy2-0.1.0-cp311-cp311-manylinux_2_31_x86_64.whl
- Upload date:
- Size: 309.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.31+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cb01c7e6394e0313fb8008ce967e7a4d6e1c71e1634fc6902e065fd4088ae1f |
|
MD5 | a6833ad96cc1f1a35a20f9e9ddbffd3f |
|
BLAKE2b-256 | 625635b67eecaa4883c5496a1c8e4224a23f43e26c2b8b2367b83238e677ea0c |
File details
Details for the file speakeasy2-0.1.0-cp311-cp311-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: speakeasy2-0.1.0-cp311-cp311-macosx_12_0_x86_64.whl
- Upload date:
- Size: 283.8 kB
- Tags: CPython 3.11, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b2fb6251d4d52b7b9ad777e17d997e3d264bc11b6ab5e0db671caaa14fdd946 |
|
MD5 | b7fabf967cadf10fa7b362ba687a63a3 |
|
BLAKE2b-256 | 04ec40e8a6aa070b714816e3c64cf94ff0a13a9f1c9e4393bcf284d695eb3f8a |
File details
Details for the file speakeasy2-0.1.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: speakeasy2-0.1.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 379.9 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3374a99799cae48f5e497079e8943cbe9f426110e1e53924fe86613648890d35 |
|
MD5 | 38bdb732a8316abc794af2c0fc5d954e |
|
BLAKE2b-256 | bd81a009d27ff8f41b99c1211d654a304a8549604b4662d680b9f802153b93bb |
File details
Details for the file speakeasy2-0.1.0-cp310-cp310-manylinux_2_31_x86_64.whl
.
File metadata
- Download URL: speakeasy2-0.1.0-cp310-cp310-manylinux_2_31_x86_64.whl
- Upload date:
- Size: 309.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.31+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a84962f4391d91ddc6bb78baff26506ebf4e647560d22f00a793dfb5910ebce |
|
MD5 | 6b34027aa68bcadbfad9439f7c5f088c |
|
BLAKE2b-256 | ad1055e80f87bbc06c14d9c0704686daee5dfba166aecf6c6f338bb8df29c282 |
File details
Details for the file speakeasy2-0.1.0-cp310-cp310-macosx_12_0_x86_64.whl
.
File metadata
- Download URL: speakeasy2-0.1.0-cp310-cp310-macosx_12_0_x86_64.whl
- Upload date:
- Size: 283.8 kB
- Tags: CPython 3.10, macOS 12.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c578fedf08630c49fe25fdfef772970508cc78eda4dc8f598d198f25379af879 |
|
MD5 | a5555662849810f35ba44f1ab7b7b801 |
|
BLAKE2b-256 | 651a17b7aa0dd2be53441a721577977762111af5adbdf4ae5ffb5ffd09b6bfc0 |