Library of algorithms for detecting communities in graphs
Project description
communities
communities
is a collection of community detection algorithms for graphs. It provides the following algorithms:
- Louvain's modularity
- Girvan-Newman
- Hierarchical clustering (TODO)
- Minimum cut (TODO)
Installation
communities
can be installed with pip
:
$ pip install communities
Getting Started
Each algorithm expects an adjacency matrix representing an undirected graph. This matrix can either be left-triangular or symmetric. To get started, just import the algorithm you want to use from communities.algorithms
, like so:
from communities.algorithms import girvan_newman
adj_matrix = [...]
communities = girvan_newman(adj_matrix)
The output of each algorithm is a list of communities, where each community is a set of nodes.
API
communities.algorithms
louvain_modularity(adj_matrix : list, size : int = None) -> list
girvan_newman(adj_matrix : list, size : int = None) -> list
communities.utilities
is_left_triangular(adj_matrix : list) -> bool
`symmetrize_matrix(adj_matrix : list) -> list
`binarize_matrix(adj_matrix : list, threshold : float = 0.0) -> list
`create_intercommunity_graph(adj_matrix : list, communities : list, aggr : Callable = sum) -> list
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
communities-2.1.0.tar.gz
(5.6 kB
view hashes)