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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ig_degree_betweenness-0.1.4.tar.gz
  • Upload date:
  • Size: 5.2 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.4.tar.gz
Algorithm Hash digest
SHA256 d14689199c77196ef7804b4de82badd6e918b910216df687587c75865ea5c092
MD5 53098ae83b6d20a69eef9492545558b3
BLAKE2b-256 e7a2bf1b859c5ce9ad5e00019a397412d33b1a9b2c0474d66fde084977a80813

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ig_degree_betweenness-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6de9797659314b15fe64ab9ed190f2135e3dd80ef88a434a75f18ab90bd7e5db
MD5 d58c862a647f458562986e3ec744ecdd
BLAKE2b-256 85bb0a48343b8aa5f4ac9c2be4aef8fb0e178cc8e1ad6674fc96cb38eb2bd64a

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