Skip to main content

Computes the clustering coefficient of nodes as defined by Watts & Strogatz (in their 1998 paper).

Project description

Clustering Coefficient

This script allows to compute Watts & Strogatz's clustering coefficient of nodes in a graph $G = (V, E)$. It is defined as the edge density of the graph induced from neighbors of a node, relatively to a clique of comparable size. More precisely, given a node $u \in V$, denoting its set of neighbors as $N_G(u)$, the clustering coefficient of $u$ is equal to:

$C_G(u) = \frac{|E(N_G(u))|}{d(d-1)/2}$

where $d = |N_G(u)|$ is the degree of node $u$ (its number $|N_G(u)|$ of neighbors).

Installing and using the plugin

The library relies on tulip-python, a python binding of the C++ Graph Visualization framework Tulip. Tulip also comes as a GUI.

Several libraries need to be installed prior to using the plugin, that can for instance be installed running poetry install --no-root. The specific dependencies are listed as part of the pyproject.toml file. A simple test script can optionally be run.

The plugin itself is typically used as:

# assuming a graph as already been defined
params = tlp.getDefaultPluginParameters('Clustering Coefficient', graph)
clustering = graph.getDoubleProperty('clustering coeff')
params['result'] = clustering
graph.applyDoubleAlgorithm('Broker score', clustering, params)

Alternatively, the plugin may be used within the Tulip GUI after the script has been loaded and ran.

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

clustering_coefficient-0.1.1.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

clustering_coefficient-0.1.1-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

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