Package to detect and find the local community broker score with a known partition
Project description
Community Broker Score
The community broker score quantifies brokers reach and control at the meso level in social networks. The measure was developed in: Paquet-Clouston, M., Bouchard, M. (2022) A Robust Measure to Uncover Community Brokerage in Illicit Networks. Journal of Quantitative Criminology https://doi.org/10.1007/s10940-022-09549-6
All information about the measure can be found here: https://link.springer.com/article/10.1007/s10940-022-09549-6. This repository allows one to calculate the community broker score as presented in the study on one's own networks, as explained below.
Local Community Broker Score:
The local community broker score is calculated for each partition (also known as a community structure) found through a community detection algorithm (in the paper, we used the Leiden algorithm). This local score quantifies, for each bridge created between two different communities, the bridge’s size (the number of people connected through the bridge), efficiency (how easily these people can be reached (i.e., cohesion) and exclusivity (whether other brokers connect these two communities).
Global Community Broker Score:
The global community broker score is an average of all local scores, making it robust to the inherent randomness of community partitioning. The averaged global score thus follows the partition distribution found when running the community detection algorithm thousands of times. This implies that a partition that emerges more often has more weight than an outlier partition (although the outlier partitions are still considered).
This package allows one to calculate the local community broker score given a known partition. Info package: https://pypi.org/project/Community-Broker-Score/
Format of edge and node files:
A node dataframe with two mandatory ordered columns:
- Column 1: id of each unique node
- Column 2: id of the community in which each unique node belongs
An edge dataframe with the first two columns representing an undirected relationship (a tie or an edge or a pair) between two nodes.
Procedure
Package info: https://pypi.org/project/Community-Broker-Score/
Install Package
pip install Community-Broker-Score
Import package in environment:
from community_broker_score import community_broker_score as cb
Needed Python libraries (library dependencies):
pandas as pd
numpy as np
networkx as nx
Package Functions:
Calculate the local community broker score
cb.local_community_broker_score(nodes, edges)
Extract the cohesion score (average_shortest_path_length from networkx), number of people and number of brokers for each community
cb.find_community_characteristics(nodes, edges)
Detect each edge that is a bridge between two communities and create a dataframe with only these edges
cb.detect_brokering_edges(nodes, edges)
Detect community brokers and tag them as such in the node dataframe
cb.detect_community_brokers(nodes, edges)
Example
An example is provided in a Jupyter Notebook on this Github repository: https://github.com/Masarah/community_broker_score
Testing
Using pytest
python -m pytest tests/test_broker_score.py
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 Distribution
File details
Details for the file Community_Broker_Score-0.1.5.tar.gz
.
File metadata
- Download URL: Community_Broker_Score-0.1.5.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81ecca57f871093b407bc8a90585a38339644db1d510cfe2d9b28a6d5047f762 |
|
MD5 | 9b870d04927155c1d9ec6ecb4f016031 |
|
BLAKE2b-256 | b01864c4eb781438fc2ede21457c0d949989e18c70bd5287644f79c50216ef1f |
File details
Details for the file Community_Broker_Score-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: Community_Broker_Score-0.1.5-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fce54a1180b4939cfb66e7b5ef254f9adaa9a03f17e76b744a57e0cbce2cd39 |
|
MD5 | 3afc30cb800fde00b733562203bce160 |
|
BLAKE2b-256 | 2a78a61ad3f8eabd9225ee5e5de530ba758fb3fabc61914eb566f4a59aa86992 |