Skip to main content

Meso level network measure pbroker score as defined by Paquet-Clouston and Bouchard

Project description

Broker Score

This script offers an alternative to Paquet-Clouston an Bouchard python package computing their meso level broker score defined on nodes of a network. Please refer to their paper:

Paquet-Clouston, M., & Bouchard, M. (2023). A Robust Measure to Uncover Community Brokerage in Illicit Networks. Journal of Quantitative Criminology, 39(3), 705-733.

or to their GitHub repository for code relying on pandas dataframes and networkx to store network data and compute the score. Our approach alternatively relies on tulip-python, a python binding of the C++ Graph Visualization framework Tulip.

Our code follows from the reformulation of Paquet-Clouston and Bouchard formula as a vector and matrix product (allowing to use numpy linear algebra routines). The measure is based on quantities $NBC_{C, C'}$ equal to the number of nodes in community $C$ acting as brokers for community $C'$. It can be obtained by computing a meso level (community level) matrix $M = (m_{C,C'})$ for $C, C' \in {\bf C}$ where $m_{C,C'}$ is equal to:

  • 1 if $C = C'$
  • $\frac{1}{\sqrt{NCB_{C, C'}}}$ if $NCB_{C, C'} \not = 0$
  • 0 otherwise

We also need to consider a community level vector: ${\bf C} = (\frac{|C|}{coh(C)})$ indexed by communities $C \in {\bf C}$, where $coh(C)$ refers to the internal cohesion of a community (Paquet-Clouston and Bouchard define it as the average path length within a community). Given a node, one can form a vector $\Delta_u = (\delta_{C,u})$ (indexed by communities $C\in {\bf C}$ as well) indicating communities to which a broker node $u$ connects, where $\delta_{C, u}$ is equal to:

  • 1 if $C \in {\bf C}(u)$
  • 0 otherwise

with the final broker score of a node being equal to the product $(\Delta_u \otimes {\bf C}) \cdot M$ (where $\otimes$ indicates the Hadamard product).

The code

The main class BrokerScore implements all necessary methods, partly relying on the Dijkstra class to run a dfs and compute a community cohesion score. In order to stick with Paquet-Clouston and Bouchard definition of cohesion, we invoke networkX average path length routine which requires to convert from Tulip into the iGraph format.

The score is computed in a matter of (tenth of a) seconds for graph containing thousands of nodes and edges and even faster for smaller graphs.

Using the script from within Tulip

You may either use the code as a script, which will load a plugin after it is run. You then need to invoke the plugin through the GUI, paying attention to the parameters the plugin needs to properly run. Another avenue is to invoke the pluging through a script, typically in the main function:

def main(graph):
    params = tlp.getDefaultPluginParameters('Broker score', graph)
    community = graph.getIntegerProperty('community')
    params['communities'] = community
    broker = graph.getDoubleProperty('broker_score')
    params['result'] = broker
    graph.applyDoubleAlgorithm('Broker score', broker, params)

Note that the BrokerScore class can be used to build a sub-network (induced subgraph) solely consisting of brokers. The construct can be iterated, as not all brokers act as broker iin the broker network. The iteration ultiately ends, giving rise to a hierarchyof sub-networks.

Dependencies

The BrokerScore class depends on a set of libraries that should be installed using the accompanying requirements.txt file. Note that versions have not been tightfully checked and my depend on how these third party libraries evolve.

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

brokerscore-0.1.3.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

brokerscore-0.1.3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file brokerscore-0.1.3.tar.gz.

File metadata

  • Download URL: brokerscore-0.1.3.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.5 Darwin/23.2.0

File hashes

Hashes for brokerscore-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0c9b9826d3f12f73e3046e473b4b1e5295b31dd632be00c3a70436e77680e981
MD5 c7cd0bf8893863984074b857d4e223b8
BLAKE2b-256 67c23b6c2b4bd9100203fe4b1dd6c179924c9700f21ab62a2a2a6d3f888ed877

See more details on using hashes here.

File details

Details for the file brokerscore-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: brokerscore-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.5 Darwin/23.2.0

File hashes

Hashes for brokerscore-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 041a6e95b964ec85fe90f565683a7110f34f52d58b8fed62875dcc53e18f9c51
MD5 837f05484bf279a93d395647c57f41bc
BLAKE2b-256 620cf2a5132ddb02694d32a6580921047a5ec2a0aeafbeb65164f2ed16bb7db5

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