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.2.tar.gz (4.7 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.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ig_degree_betweenness-0.1.2.tar.gz
  • Upload date:
  • Size: 4.7 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.2.tar.gz
Algorithm Hash digest
SHA256 96a9816175493529397bd915666e15b4a0af0b18373b8e2b95a62ad6fbd1a772
MD5 bd0f8b0362ffea1a158cda09f6ff444b
BLAKE2b-256 0da7899ec57353917f045d360398953d97194e41d8ff032acc06cd7cf02d1806

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ig_degree_betweenness-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d3113dc8a8c49ae52241fedde70a13b4029f0e254f52a76ec585b988f955b157
MD5 1274a5608d186979c73d5291f2c11ace
BLAKE2b-256 ad8f44f98e7f55c758be3f2d181ffd758705269e51f4a69ff9c778e7b8f49b93

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