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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scigraphs_utils-0.2.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: scigraphs_utils-0.2.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ae8497b5ef6ac0bf5bb62a09434c11280d3dd1f0f50c28c2b0bc09676ad191f
|
|
| MD5 |
65b2b92c749706cd8d946d2d416cba41
|
|
| BLAKE2b-256 |
1b837e876a8fd60e90e2df456225f229d87acfb9156e90ceae90fd64dcee050e
|
Provenance
The following attestation bundles were made for scigraphs_utils-0.2.0-cp313-cp313-win_amd64.whl:
Publisher:
publish.yml on josemarinfarina/scigraphs-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scigraphs_utils-0.2.0-cp313-cp313-win_amd64.whl -
Subject digest:
3ae8497b5ef6ac0bf5bb62a09434c11280d3dd1f0f50c28c2b0bc09676ad191f - Sigstore transparency entry: 2583058877
- Sigstore integration time:
-
Permalink:
josemarinfarina/scigraphs-utils@fce56a296b3cd53a6f9e697f641791173a326f68 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/josemarinfarina
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fce56a296b3cd53a6f9e697f641791173a326f68 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scigraphs_utils-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: scigraphs_utils-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 5.9 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6da6c76804ea25b7bc3a8d80845937fdb9cf8f2caac7cc23f6853bd53632f82a
|
|
| MD5 |
07877ba879554f9bbb0366e4eb65880d
|
|
| BLAKE2b-256 |
7b294cdf959720c979a04fa68d560b16bf97dcca2d864dd51fdc9b3f0bf5573c
|
Provenance
The following attestation bundles were made for scigraphs_utils-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
publish.yml on josemarinfarina/scigraphs-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scigraphs_utils-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
6da6c76804ea25b7bc3a8d80845937fdb9cf8f2caac7cc23f6853bd53632f82a - Sigstore transparency entry: 2583058896
- Sigstore integration time:
-
Permalink:
josemarinfarina/scigraphs-utils@fce56a296b3cd53a6f9e697f641791173a326f68 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/josemarinfarina
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fce56a296b3cd53a6f9e697f641791173a326f68 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scigraphs_utils-0.2.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: scigraphs_utils-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 924.4 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04f933aa9d36660cec41201099d0628457920578c965ce5220175e8c5a92c694
|
|
| MD5 |
64fa9515add91cd4a7daada8aca4137a
|
|
| BLAKE2b-256 |
776c74a348ffed0d3c53c100b015dbe0246fc053d8c9e54806991ecc955f588d
|
Provenance
The following attestation bundles were made for scigraphs_utils-0.2.0-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
publish.yml on josemarinfarina/scigraphs-utils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scigraphs_utils-0.2.0-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
04f933aa9d36660cec41201099d0628457920578c965ce5220175e8c5a92c694 - Sigstore transparency entry: 2583058914
- Sigstore integration time:
-
Permalink:
josemarinfarina/scigraphs-utils@fce56a296b3cd53a6f9e697f641791173a326f68 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/josemarinfarina
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fce56a296b3cd53a6f9e697f641791173a326f68 -
Trigger Event:
push
-
Statement type: