Skip to main content

BiWES – Bipartite Weighted Edge Shuffling: randomisation of bipartite weighted graphs preserving degree and weight sequences.

Project description

BiWES — Bipartite Weighted Edge Swap

A Python library for randomising bipartite weighted graphs while preserving their degree and weight sequences.

Installation

pip install biwes

Quick start

import numpy as np
from biwes import BiWES, BiWES2, pre_compute, find_configurations

# Create a simple bi-adjacency matrix.
# The bia-adjacency matrix must contain only integers
A = np.array([
    [2, 3, 0, 2, 0],
    [0, 1, 4, 0, 0],
    [1, 0, 2, 0, 2],
    [0, 0, 2, 1, 0],
], dtype=np.int64)

# Run 1000 randomisation steps (single call)
#The functions BiWES and BiWES2 use numba, so the first call will be slow because 
A_rand = BiWES(A, 1000)

# --- or reuse pre-computed structures for many runs ---
A2, weight_dict, weight_dict2, adj_list, adj_list2, uw, uw2 = pre_compute(A)
A_rand2 = BiWES2(A2, weight_dict, weight_dict2, uw, uw2, adj_list, adj_list2, 1_000)

#The functions BiWES and BiWES2 use numba, so the first call will be slow because

Enumerate all configurations with a given degree and strength sequences for a tiny graph

strength_a = list(np.sum(A, axis=1))
strength_b = list(np.sum(A, axis=0))
degree_a = list(np.sum(np.where(A > 0, 1, 0), axis=1))
degree_b = list(np.sum(np.where(A > 0, 1, 0), axis=0))
solutions = find_configurations(strength_a, strength_b, degree_a, degree_b)
#solutions is a list of bi-adjacency matrices

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

biwes-0.1.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

biwes-0.1.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file biwes-0.1.1.tar.gz.

File metadata

  • Download URL: biwes-0.1.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for biwes-0.1.1.tar.gz
Algorithm Hash digest
SHA256 90aed2881aa2b32c90cfddfa236e362c7920eb4170351c96a1debd0873a0b9ff
MD5 597126b21b7914ab120a839d63c75b08
BLAKE2b-256 7af6d187f98ef1a78edb1187908644fa341365ded17b396346c41d0a29ba2015

See more details on using hashes here.

File details

Details for the file biwes-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: biwes-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for biwes-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9fae1a420fa19d7ab0d438a635d13bd14f2d2a1f80176edf1c798a5697e75994
MD5 d9403bf11e67555817c49754b6cd385a
BLAKE2b-256 d517249af3239b6631cadb69413389a5aa73dce43fc167612de493e03e2f5d98

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