Shortcut sets for reachability
Add directed edges while preserving which vertices are reachable from each source.
reachq is a focused Python library for building exact reachability shortcut sets and weighted shortest-path hopsets on directed graphs. It makes the construction, query, and verification steps explicit.
The core API is usable and tested, but compatibility is not promised before 1.0. Install from a source checkout and read the explicit limits before adoption.
Keeping the code, tests, examples, and docs on one commit makes the current behavior inspectable.
The first example does not promise a speedup. It constructs a result, checks exact reachability preservation, and makes the realized bound visible.
from reachq.generators import random_dag
from reachq.shortcut import build_shortcut_set_for_reachability
from reachq.invariants import assert_reachability_preserved
graph = random_dag(n=100, edge_probability=0.1, random_seed=42)
shortcuts, beta, realised_bound = build_shortcut_set_for_reachability(
graph, omega=3.0, random_seed=42
)
assert_reachability_preserved(graph, shortcuts)Use reachq when the graph algorithm itself is the work: precompute structure, run a bounded query, and check the result against an explicit invariant.
Add directed edges while preserving which vertices are reachable from each source.
Add weighted links and query with a hop limit while keeping epsilon visible.
Seeds, bounds, serialization, and invariants make algorithmic experiments inspectable.
The library separates construction from querying so you can compare setup cost, query cost, memory, and correctness on your own graph family.
Build H, query G ∪ H, and verify that reachability is unchanged.
Build weighted links, query with max_hops, and compare distances with exact Dijkstra.
Formal results, implementation behavior, and measured performance are different kinds of evidence. The docs keep them separate.
Shortcut workflows expose an invariant for the reachable relation.
Hopset checks compare bounded paths with an exact baseline.
Insertion order and random seeds support reproducible experiments.
No blanket speedup, hosted service, or pre-1.0 compatibility promise.
The docs are organized by the question you are trying to answer: install, understand, build, reference, research, or contribute.
Install and run the first verified construction.
Start here →02Find the supported graph, query, configuration, and invariant surface.
Browse API →03Understand shortcut sets, hopsets, correctness, and limitations.
Understand the model →04Record the context needed to make a result reproducible.
Measure honestly →05Separate paper provenance from current implementation behavior.
Read the boundary →06Set up the project and make changes that stay maintainable.
Join the work →The constructions are informed by published graph-algorithm research. reachq keeps literature results, implementation facts, and benchmark observations distinct.
Read the provenance