Skip to main content

scigraphs-utils

Utilities for scientific graph layouts.

The Python import package is scigraphs_utils.

import numpy as np
from scigraphs_utils import sfdp_layout

edges = np.array([[0, 1], [1, 2], [2, 3]], dtype=np.int32)
xy = sfdp_layout(4, edges, seed=42, overlap="false", maxiter=100)

For Graphviz parameters that are not listed explicitly, pass them as keyword arguments. They are forwarded as Graphviz graph attributes:

from scigraphs_utils import graphviz_layout

xy = graphviz_layout(4, edges, engine="sfdp", start=42, K=1.2)

Barnes-Hut forces

quadtree_repulsion exposes the repulsion term sfdp uses internally: Graphviz's own QuadTree_get_repulsive_force, compiled into this package's extension. It works on 2D and 3D points and is roughly two orders of magnitude faster than an all-pairs numpy evaluation at a few thousand points.

import numpy as np
from scigraphs_utils import quadtree_repulsion

points = np.random.default_rng(0).normal(size=(20_000, 3))
forces = quadtree_repulsion(points, theta=0.6)

theta is the Barnes-Hut opening angle (sfdp uses 0.6; smaller is more accurate and slower, and theta -> 0 converges to the exact all-pairs result). Pass weights= for per-point masses, p= for a different force exponent, and return_counts=True for Graphviz's interaction counters.

quadtree_cells returns the same tree flattened into arrays, so an overlay can draw the cells the forces actually used instead of a uniform grid:

from scigraphs_utils import quadtree_cells

cells = quadtree_cells(points)
cells.lower      # (cells, dim) lower corner
cells.size       # (cells,) edge length
cells.count      # (cells,) points per cell
cells.is_leaf    # (cells,) bool

Both functions build the tree the same way, so pass matching weights and max_level to get the tree that produced a given force field.

Development

The current MVP builds a native extension against a local Graphviz installation:

python -m pip install -e ".[test]"
pytest

To build against a private Graphviz prefix, run:

tools/build_graphviz.sh
GRAPHVIZ_PREFIX="$PWD/build/vendor/graphviz-install" python -m pip install -e ".[test]"

Wheels

The project is configured for cibuildwheel CPython 3.13 builds. The wheel build hook compiles a pinned Graphviz release into a private prefix and builds the native extension against that prefix. On Linux, auditwheel then bundles the required shared libraries into the wheel so users do not need Graphviz installed at runtime.

python -m pip install ".[wheel]"
python -m cibuildwheel --output-dir wheelhouse

Pushing a v* tag runs .github/workflows/publish.yml, which builds the three wheels and uploads them to PyPI through trusted publishing.

Vendored Graphviz source

The quadtree is compiled from a copy of Graphviz's lib/sparse/QuadTree.c under vendor/graphviz/, because those symbols are not exported from the layout plugin. Those files stay under the Eclipse Public License — see THIRD_PARTY_NOTICES.md and vendor/graphviz/README.md. When bumping vendor/graphviz.version, run:

python tools/sync_quadtree.py

Metadata

Release files for scigraphs-utils 0.2.0

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

Built distributions (wheels)

Table of built distributions (wheels) for scigraphs-utils 0.2.0
File Interpreter ABI Platform Actions
scigraphs_utils-0.2.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for scigraphs_utils-0.2.0-cp313-cp313-win_amd64.whl
scigraphs_utils-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for scigraphs_utils-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
scigraphs_utils-0.2.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for scigraphs_utils-0.2.0-cp313-cp313-macosx_11_0_arm64.whl

Total release size: 7.9 MB

Release files / scigraphs_utils-0.2.0-cp313-cp313-win_amd64.whl

Download URL scigraphs_utils-0.2.0-cp313-cp313-win_amd64.whl
Size 1.1 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
3ae8497b5ef6ac0bf5bb62a09434c11280d3dd1f0f50c28c2b0bc09676ad191f
BLAKE2b-256 checksum
How to use checksums
1b837e876a8fd60e90e2df456225f229d87acfb9156e90ceae90fd64dcee050e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 25, 2026.

Transparency log

Release files / scigraphs_utils-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL scigraphs_utils-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 5.9 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
6da6c76804ea25b7bc3a8d80845937fdb9cf8f2caac7cc23f6853bd53632f82a
BLAKE2b-256 checksum
How to use checksums
7b294cdf959720c979a04fa68d560b16bf97dcca2d864dd51fdc9b3f0bf5573c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 25, 2026.

Transparency log

Release files / scigraphs_utils-0.2.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL scigraphs_utils-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Size 924.4 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
04f933aa9d36660cec41201099d0628457920578c965ce5220175e8c5a92c694
BLAKE2b-256 checksum
How to use checksums
776c74a348ffed0d3c53c100b015dbe0246fc053d8c9e54806991ecc955f588d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 25, 2026.

Transparency log

Security for scigraphs-utils 0.2.0

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.

Full provenance

All 3 files in this release have been uploaded with provenance metadata.

Select from 3 files

Attestation for scigraphs_utils-0.2.0-cp313-cp313-win_amd64.whl

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 Aug 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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