Skip to main content

Ask DeepWiki CI Coverage PyPi PyPi Python 3.12 Python 3.11 Python 3.10

Red-Black Graph - A DAG of Multiple, Interleaved Binary Trees

Introduction

Red-Black Graphs are a specific type of graph, a directed acyclic graph of interleaved binary trees. This data structure resulted from exploration of efficient representations for family history. This package presents and implements the underlying linear algebra as well as discusses some interesting applications.

This python module extends both scipy and numpy and also conforms to dockerutils conventions for building and running docker images used in module development. There is a script in the bin directory that can be used to setup the project for development or to prep for reading the notebook. (bin/setup-project.sh). You will want to create an activate a virtual environment prior to running the script.

Reading the Notebook

A research paper describing the linear algebra underlying Red-Black graphs as well as examples of application can be found in the Jupyter notebook, "Red Black Graph - A DAG of Multiple, Interleaved Binary Trees.ipynb". To access the notebook after you've setup the project for development, simply:

  • run-image notebook
  • open http://localhost:8888/lab

If you'd prefer to read hard copy, simply run:

`bin/generate-pdf.sh notebooks/Red Black Graph - A DAG of Multiple, Interleaved Binary Trees.ipynb` 

A pdf file will be generated into the build/latex-{datestamped} directory.

To Try Things Out...

Run the following:

# use crawl-fs to extract a sample data set from FamilySearch
pip install fs-crawler
crawl-fs -i <FamilySearch Ids to seed crawl> -o <output-directory> -b <name portion of output file>

# this will generate a <name>.vertices.csv and <name>.edges.csv file which can be ingested into a RedBlackGraph
pip install RedBlackGraph
# use rbgcf to generate both a simple form and cannonical form of a Red Black Graph (xlsx files)
rbgcf -f <directory and base name of vertices and edges file> -o <output-directory>

# Use excel to view output
 

Building from Source

RedBlackGraph uses the Meson build system (as of version 0.5.0, migrated from numpy.distutils).

Requirements

  • Python 3.10, 3.11, or 3.12
  • Meson >= 1.2.0
  • Ninja build tool
  • Cython >= 3.0
  • NumPy 1.26+ (including NumPy 2.x)

Build and Install

# Install build dependencies
pip install meson-python meson ninja cython numpy

# Build and install in development mode
pip install -e . --no-build-isolation

# Or build wheel
pip install build
python -m build

uv users

Meson-python editable installs require --no-build-isolation (the editable loader needs a persistent build directory). A setup script handles this:

./bin/setup-uv.sh           # CPU only
./bin/setup-uv.sh --gpu     # Include CuPy for GPU support
source .venv/bin/activate
pytest tests/

Or manually:

uv venv
uv pip install meson-python meson ninja cython tempita numpy
uv pip install -e ".[test,io]" --no-build-isolation

uv setup script

If you use uv, a convenience script is provided to create a fresh .venv, install build/test dependencies, perform an editable install using pip with --no-build-isolation, and install the test extra:

./bin/setup-uv.sh
source .venv/bin/activate
uv run -m pytest

The script expects:

  • uv on your PATH
  • the ninja build tool installed (e.g. sudo apt install ninja-build on Debian/Ubuntu)
  • the fs-crawler submodule present at ./fs-crawler

The Meson build system compiles all C/C++ extensions and Cython modules automatically.

Building and Publishing Wheels

RedBlackGraph uses cibuildwheel to build wheels for multiple platforms and Python versions.

Quick Start

# Build wheels for current platform
./bin/build-wheels-cibuildwheel.sh

# Or use cibuildwheel directly
pip install cibuildwheel
cibuildwheel --platform auto --output-dir wheelhouse

Automated Release

Wheels are automatically built and published to PyPI when a version tag is pushed:

git tag -a v0.5.1 -m "Release version 0.5.1"
git push origin v0.5.1

For detailed instructions, see:

A Note on Implementations

  • redblackgraph.reference - a pure python implementation. This simple implementation is intended primarily for illustrative purposes.
  • redblackgraph.matrix and redblackgraph.array - a Numpy C-API extension for efficient computation with the matrix multiplication operator, @, overloaded to support avos sum and product.
  • redblackgraph.sparse_matrix - an optimized implementation built on scipy's sparse matrix implementation.
  • redblackgraph.gpu - GPU-accelerated sparse operations using CuPy and inline CUDA kernels. Provides SpGEMM (sparse matrix multiply) and transitive closure on GPU using the AVOS semiring.

GPU Acceleration

The GPU module (redblackgraph.gpu) provides two transitive closure algorithms:

  1. Repeated squaring (transitive_closure_gpu) — works for any graph. Computes TC(A) = A + A² + A⁴ + ... via CUDA SpGEMM with all data GPU-resident between iterations.
  2. Level-parallel DAG propagation (transitive_closure_dag_gpu) — specialized for DAGs (triangular matrices). Processes vertices by topological level with full GPU parallelism within each level.

Performance

Benchmarked on synthesized family DAGs (lower-triangular adjacency matrices). CPU uses the Cython O(V+E+nnz) topological propagation algorithm.

Vertices NNZ CPU-DAG (s) GPU-Sqr (s) GPU-DAG (s) Best GPU/CPU
442 1,226 0.0020 0.0039 0.0032 1.6x CPU
1,326 3,728 0.0080 0.0055 0.0038 2.1x GPU
2,144 5,932 0.0129 0.0059 0.0043 3.0x GPU
4,701 13,103 0.0292 0.0073 0.0057 5.1x GPU
11,012 30,536 0.0700 0.0125 0.0087 8.1x GPU
21,162 58,486 0.1380 0.0268 0.0138 10.0x GPU

GPU crossover is ~1,000 vertices. The DAG kernel nearly doubles the speedup over repeated squaring at scale.

Requirements

pip install cupy-cuda12x  # or cupy-cuda11x for older CUDA

GPU features are optional — all functionality gracefully falls back to CPU when CuPy is unavailable.

Quick Start

from redblackgraph.gpu import CSRMatrixGPU, transitive_closure_dag_gpu

# Transfer sparse matrix to GPU
A_gpu = CSRMatrixGPU.from_cpu(my_sparse_matrix)

# Compute transitive closure
closure, diameter = transitive_closure_dag_gpu(A_gpu)

# Transfer result back to CPU
result = closure.to_cpu()

Run python bench_closure.py to reproduce the benchmark on your hardware.

Release files for redblackgraph 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redblackgraph 0.7.0
File Size Uploaded
redblackgraph-0.7.0.tar.gz 893.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for redblackgraph 0.7.0
File
redblackgraph-0.7.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
redblackgraph-0.7.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
redblackgraph-0.7.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
redblackgraph-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.13+ x86-64 Details
redblackgraph-0.7.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
redblackgraph-0.7.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
redblackgraph-0.7.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
redblackgraph-0.7.0-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details
redblackgraph-0.7.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
redblackgraph-0.7.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
redblackgraph-0.7.0-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
redblackgraph-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details

Total release size: 12.8 MB

Release files / redblackgraph-0.7.0.tar.gz

Download URL redblackgraph-0.7.0.tar.gz
Size 893.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2b1cc3d12bd44419258708306cadb320e292a5d195f41d1c474fd776bdef5fc0
BLAKE2b-256 checksum
How to use checksums
d57f252e256d69fed4b260fadfe011b6d28aef305c622c53e4f33a22d052208d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp312-cp312-win_amd64.whl

Download URL redblackgraph-0.7.0-cp312-cp312-win_amd64.whl
Size 1.1 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
ca7876c1eac77d412a95cfef02c046ca25450586078bead6a0ab7590c1c89a5f
BLAKE2b-256 checksum
How to use checksums
db0fec129a15de7adc98e3b802654c49ffb1a812faeca56c4fa794062b31cfc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL redblackgraph-0.7.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
214ea2bb6b910e1728805a36dd26a68feabd78439e1021bfc6094d85f8ece9b2
BLAKE2b-256 checksum
How to use checksums
648ec994c7221ab8771ebb3968e7675e1a49c57505ef277858f30662fa280226
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL redblackgraph-0.7.0-cp312-cp312-macosx_11_0_arm64.whl
Size 852.7 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
75694bff7a9b6b9d50cd73b4a07c9e117c433d3d91fb399195bd1fb5ad5f9659
BLAKE2b-256 checksum
How to use checksums
44d15296cd853d44680e87c5bea51de4ffbcf2a8812476192079c5772089de79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl

Download URL redblackgraph-0.7.0-cp312-cp312-macosx_10_13_x86_64.whl
Size 890.9 kB
Tags CPython 3.12 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
6cd4eeb41d220482aaad2580a0d41043b071c45ccdb38e18fcb47c22eaf9e632
BLAKE2b-256 checksum
How to use checksums
5659fb9de87962e020ce9a8979bec8a156acdba3412f4b243774cf771a1fd877
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp311-cp311-win_amd64.whl

Download URL redblackgraph-0.7.0-cp311-cp311-win_amd64.whl
Size 1.1 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
584da7e3979b24a56e4cd2c8d971d1a490f65cfb545cce68f44e1c0e2ef7d23a
BLAKE2b-256 checksum
How to use checksums
99d5142f5efe5bbc8875c4eb257a67be3d8edf92fc808e0ebb58a07f6e4d5595
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL redblackgraph-0.7.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 1.2 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c9d14bb163d52b33b5f68c05ba70bb5e3cf22e4e18fab6471216607818d963a1
BLAKE2b-256 checksum
How to use checksums
81e21fea7de61eef2dab72c134524a329f48b1719c25ddf248c55f9f14d578aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL redblackgraph-0.7.0-cp311-cp311-macosx_11_0_arm64.whl
Size 853.4 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d52cd62525c63b7c0cf40efde7434009ff2d7deb6c49ac3ecbdff5dbcbd8915c
BLAKE2b-256 checksum
How to use checksums
c6d07243ecaadaf0949de3b6eba7239b9ee11c227f90adc1f1f7c5b810778533
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp311-cp311-macosx_10_9_x86_64.whl

Download URL redblackgraph-0.7.0-cp311-cp311-macosx_10_9_x86_64.whl
Size 900.6 kB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
603fc6a1b560c43b6ee64d03548e843b5c99da0b326d696f19c27cff16cc559c
BLAKE2b-256 checksum
How to use checksums
3a582587e8790a8cda792756b1b5965fc9b82757fbfbc828227e2220c94f9b44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp310-cp310-win_amd64.whl

Download URL redblackgraph-0.7.0-cp310-cp310-win_amd64.whl
Size 1.1 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
5f0b5fed54341beb8a66f751178593102da7861f4c06d10c87176829777ecab2
BLAKE2b-256 checksum
How to use checksums
501f5af462419237f1c9a47cdc6493fe917ee14d711d2eb7c8ddc7872aa15f5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL redblackgraph-0.7.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 1.2 MB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
559afbd194f9f9a06aafcb20cf327ac17da6b0b8c3443989ccca528dffc355cd
BLAKE2b-256 checksum
How to use checksums
6c4358d53a1adf806f12e6c395f5a5bb4cea8fa853eb1c6a3adcb11ac1a6cc0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp310-cp310-macosx_11_0_arm64.whl

Download URL redblackgraph-0.7.0-cp310-cp310-macosx_11_0_arm64.whl
Size 860.9 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4e79f053003731015a4a639281c79421b77763440d62b5a612630e3db2c16b2e
BLAKE2b-256 checksum
How to use checksums
c5c988ed9d9d351b00c54404cd5bef8f9460f5f526d32810321c8b14ba331e65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / redblackgraph-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl

Download URL redblackgraph-0.7.0-cp310-cp310-macosx_10_9_x86_64.whl
Size 907.7 kB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
d573786c565138d7f707358991b0a090bdde0fd2137489ef5400bceb2fba9fb5
BLAKE2b-256 checksum
How to use checksums
9c7bf60c71dd99f424ad6e02f1b2a9406a23917b0491bda44d5cd4063737a66e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.0 This release

13 release files

0.5.1

13 release files

0.5.0

1 release file

0.3.15

9 release files

0.3.14

9 release files

0.3.12

9 release files

0.3.11

9 release files

0.3.10

9 release files

0.3.9

9 release files

0.3.8

9 release files

0.3.7

9 release files

0.3.6

9 release files

0.3.5

9 release files

0.3.4

9 release files

0.3.3

9 release files

0.3.2

2 release files

0.3.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page