Skip to main content

Smith-Pittman Community Detection Algorithm for 'igraph' Objects (2024)

Project description

ig_degree_betweenness_py

PyPI - Version Pepy Total Downloads arXiv

Python implementation of the Smith-Pittman Algorithm available in the ig.degree.betweenness R package.

This code can be used both as a standard Python library for scripting and as a command-line tool.

Installation

To install from PyPI, run:

pip install ig-degree-betweenness

To install from GitHub, run.

pip install git+https://github.com/benyamindsmith/ig_degree_betweenness_py.git

Usage

Scripting Usage

To use this in a typical scripting setting compute the clustering with the following code.

import igraph as ig
from ig_degree_betweenness import community_degree_betweenness
import matplotlib.pyplot as plt


# Read edges
with open("edgelist.txt", "r") as f:
    edges = [tuple(line.strip().split("\t")) for line in f]

# Build graph with directed flag
g = ig.Graph.TupleList(edges, directed=True)

# Compute clustering
sp_clustering = community_degree_betweenness(g)

This can be further visualized:

# Visualize Communities
fig1, ax1 = plt.subplots()
ig.plot(
    sp_clustering,
    target=ax1,
    mark_groups=True,
    vertex_size=15,
    edge_width=0.5,
)
fig1.set_size_inches(20, 20)

To run this code in the terminal, run:

Terminal Usage

# for an undirected graph (default)
$ python ig_degree_betweenness my_edges.txt

# for a directed graph
$ python ig_degree_betweenness -d my_edges.txt

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

ig_degree_betweenness-0.1.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ig_degree_betweenness-0.1.3-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ig_degree_betweenness-0.1.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for ig_degree_betweenness-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7719eb5b24853b1db41c1fe15fd5a911f0036ee4ef7d21c1b0248c97f256d2ff
MD5 5c00b28c1a653d4a809d3f3336fa8afc
BLAKE2b-256 9467333a296108115bcf938625784f310d87cdf3fc44cba60d26c7d8671eaf28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ig_degree_betweenness-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f96f2f8c291e22af7464567ce0965bbd6302c773bf8e8c6ca5aaa1d64e150888
MD5 b892548b60effc2da9a9bcb94812b07d
BLAKE2b-256 e023b38d77f4244c76b1e9f4f44e3eb13b6dd64c8b5e469f9602ac1c275d7aa8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page