Skip to main content

A python library for generating ABCD graphs.

Project description

abcd-graph

A python library for generating ABCD graphs.

Installation

Using pip

pip install abcd-graph

Project available at PyPI.

From source

git clone
cd abcd-graph
pip install .

Usage

from abcd_graph import Graph, ABCDParams

params = ABCDParams()
graph = Graph(params, n=1000, logger=True).build()

Parameters

  • params: An instance of ABCDParams class.
  • n: Number of nodes in the graph.
  • logger A boolean to enable or disable logging to the console. Default is False - no logs are shown.
  • callbacks: A list of instances of Callback class. Default is an empty list.

Returns

The Graph object with the generated graph.

Graph generation parameters - ABCDParams

The ABCDParams class is used to set the parameters for the graph generation.

Arguments:

Name Type Description Default
gamma float Power-law parameter for degrees, between 2 and 3 2.5
delta int Min degree 5
zeta float Parameter for max degree, between 0 and 1 0.5
beta float Power-law parameter for community sizes, between 1 and 2 1.5
s int Min community size 20
tau float Parameter for max community size, between zeta and 1 0.8
xi float Noise parameter, between 0 and 1 0.25

Parameters are validated when the object is created. If any of the parameters are invalid, a ValueError will be raised.

Exporting

Exporting the graph to different formats is done via the exporter property of the Graph object.

Possible formats are:

Method Description Required packages Installation command
to_networkx() Export the graph to a networkx.Graph object. networkx pip install abcd[networkx]
to_igraph() Export the graph to an igraph.Graph object. igraph pip install abcd[igraph]
adj_matrix Export the graph to a numpy.ndarray object representing the adjacency matrix.
to_sparse_adjacency_matrix() Export the graph to a scipy.sparse.csr_matrix object representing the adjacency matrix. scipy pip install abcd[scipy]
to_edge_list() Export the graph to a list of tuples representing the edges.

Example:

from abcd_graph import Graph, ABCDParams

params = ABCDParams()
graph = Graph(params, n=1000, logger=True).build()
graph_networkx = graph.exporter.to_networkx()

Callbacks

Callbacks are used to handle diagnostics and visualization of the graph generation process. They are instances of the ABCDCallback class.

Out of the box, the library provides three callbacks:

  • StatsCollector - Collects statistics about the graph generation process.
  • PropertyCollector - Collects properties of the graph.
  • Visualizer - Visualizes the graph generation process.

Example:

from abcd_graph import Graph, ABCDParams

from abcd_graph.callbacks import StatsCollector, Visualizer, PropertyCollector


stats = StatsCollector()
vis = Visualizer()
props = PropertyCollector()
params = ABCDParams()
g = Graph(params, n=1000, logger=True, callbacks=[stats, vis, props]).build()

print(stats.statistics)

print(props.xi_matrix)

vis.draw_community_cdf()

Docker

To build a docker image containing the library, run:

docker build -t abcd-graph .

To run the image, use:

docker run -it abcd-graph /bin/bash

This will give you a terminal inside a container with the library installed.

Available are also installation commands for the additional packages:

docker build -t abcd-test --build-arg INSTALL_TYPE=igraph .

Possible values for INSTALL_TYPE are dev, matplotlib, networkx, igraph, scipy, all and extended.

Value Packages installed
dev pytest, pre-commit, pytest-cov
matplotlib matplotlib
networkx networkx
igraph igraph
scipy scipy
all networkx, igraph, scipy, pytest, pre-commit, pytest-cov, matplotlib
extended scipy, matplotlib

[!NOTE] Combinations of the above values are also possible, e.g. igraph,networkx.

[!WARNING] If you choose and option outside the available ones, the installation will still succeed, but only the base package will be installed.

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

abcd_graph-0.3.0rc1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

abcd_graph-0.3.0rc1-py3-none-any.whl (32.0 kB view details)

Uploaded Python 3

File details

Details for the file abcd_graph-0.3.0rc1.tar.gz.

File metadata

  • Download URL: abcd_graph-0.3.0rc1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.5.0-1025-azure

File hashes

Hashes for abcd_graph-0.3.0rc1.tar.gz
Algorithm Hash digest
SHA256 4a4a8734c52f4426d7106cc3affa71b54c9c01aed3c67017c756483d9d18f754
MD5 ffbe89c023d340da5d49bf9aa106be0e
BLAKE2b-256 2e60908ae863e496a302913ffcff3a9886179ba287bfe43021c1eff19d1fe7c9

See more details on using hashes here.

File details

Details for the file abcd_graph-0.3.0rc1-py3-none-any.whl.

File metadata

  • Download URL: abcd_graph-0.3.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 32.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.5.0-1025-azure

File hashes

Hashes for abcd_graph-0.3.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 a2e63498cf7ab474e7363a0d06a8f014ac2f7d574ba9ff767fcb0bef7d90db9c
MD5 1d85bba5022bf13f00c59767c89dc12a
BLAKE2b-256 e784eb7950afce11af258295110bbd43512560ff3fafc0160636a6d85c7afbc4

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