Skip to main content

Sampling algorithm of network hyperbolic embeddings.

Project description

BIGUE hyperbolic embedder

isolated

Bayesian Inference of a Graph's Unkown Embedding (BIGUE) is a Markov Chain Monte Carlo algorithm that samples the best hyperbolic embeddings of a given network according to a Bayesian $\mathbb{S}^1$ model.

The code used to generate the Figures in the paper is in the bigue-analysis repository. If you use this algorithm, please cite:

Simon Lizotte, Jean-Gabriel Young and Antoine Allard "Symmetry-driven embedding of networks in hyperbolic space". Commun. Phys. 8, 199 (2025). https://doi.org/10.1038/s42005-025-02122-0

Installation

Dependencies

The pybigue library requires:

  • Python (>= 3.10)
  • NumPy
  • SciPy
  • CmdStanPy
  • Numba

pybigue can be installed directly from PyPi

pip install pybigue

Usage

To use the default BIGUE sampler,

from pybigue.sampling import sample_bigue, read_sample

# ... code that obtains an numpy adjacency matrix

sample_directory = "./sample/"
sample_bigue(adjacency_matrix, sample_directory) # Writes samples to disk
samples = read_sample(sample_directory) # Reads samples

Two complete examples are presented in the examples. The file embed_synthetic_graph.py uses the default BIGUE algorithm (requires also matplotlib) and the file manual_sampling.py shows how one can tweak the sampler (hyperparameter values, prior distributions, subkernel selection probabilities, combining with Stan HMC, etc.).

Note that the samples are not aligned automatically. This Python library doesn't provide a tool to compute automorphisms. This can be found in the bigue-analysis repository. Nevertheless, the samples can be aligned given a list of automorphisms

from pybigue.models import S1Model

# Each automorphism is an array of the new label of each vertex.
automorphisms = [np.arange(adjacency_matrix.shape[0])] # Trivial automorphism
aligned_samples = {
    chain: S1Model.align_sample(sample, reference_thetas=some_thetas, automorphisms=automorphisms)
        for chain, sample in samples.items()
}

Source code

The lastest version can be fetched with

git clone https://github.com/DynamicaLab/bigue.git

Testing

After downloding the code, the test suite can be ran using (requires installing pytest)

pytest pybigue

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

pybigue-1.0.0.tar.gz (37.5 kB view details)

Uploaded Source

Built Distribution

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

pybigue-1.0.0-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

Details for the file pybigue-1.0.0.tar.gz.

File metadata

  • Download URL: pybigue-1.0.0.tar.gz
  • Upload date:
  • Size: 37.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for pybigue-1.0.0.tar.gz
Algorithm Hash digest
SHA256 22884b5377eeebf0cac8cf72069212a1f72368ec670ba63c45ddea3d7b6fcfc9
MD5 e12f85bacd5634e935d491677a9e018e
BLAKE2b-256 3cefb8f01e60b3cda74e22a0b39e2951dde96eb1727a2e76cf2248d69a8d6050

See more details on using hashes here.

File details

Details for the file pybigue-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pybigue-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for pybigue-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a27aa904d84fd02245bf87a9f3d327f553acec96c848ee2532798115edef375f
MD5 0b27539437af5b4adcab237bf397abcb
BLAKE2b-256 c986a64ee07e16f5b0966321cd8627fdee6de64707c633182b3f42c92aa29d68

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