Practical usage
Examples
Copyable workflows for live updates, reproducible traces, mode comparisons, and benchmark interpretation.
Paper matching modes. The examples show the in-memory Matcher API. For durable updates and concurrent local clients, use Service, which routes Basic and Multilevel through the same SQLite-backed transaction path. Do not infer the paper's complete asymptotic theorem from the current implementation.
Maintain a live stream
Keep the matcher as the owner of graph state. Feed it updates in order and inspect the matching after each operation.
from axiom import Matcher
matcher = Matcher(n=8, mode="basic")
updates = [
("insert", 0, 1),
("insert", 1, 2),
("insert", 4, 5),
("delete", 0, 1),
]
for operation, u, v in updates:
getattr(matcher, operation)(u, v)
assert matcher.maximal()
print(matcher.matching())
print(matcher.partners())
print(matcher.stats())Replay a deterministic trace
Generate a valid insert/delete sequence from a seeded random generator, save it with your experiment, and replay it against another matcher.
import random
from axiom import Matcher
from axiom.simulation import random_updates, replay
rng = random.Random(7)
trace = list(random_updates(n=50, steps=100, rng=rng))
matcher = Matcher(50, mode="multilevel")
replay(matcher, trace)
assert matcher.maximal()
print(matcher.size(), matcher.stats()["matching_size"])Compare modes
compare runs the same seeded workload in independent worker processes. Compare throughput only under the same graph size, update count, and seed.
from axiom.parallel import compare
if __name__ == "__main__":
results = compare(n=100, updates=1_000, seed=42)
for mode, result in results.items():
print(mode, round(result.updates_per_sec), result.is_maximal)Run this from a Python file or module. The main guard is required on platforms that use the spawn multiprocessing start method.
Command line smoke test
$ axiom --n 20 --mode basic --updates 200 --seed 42
Completed 200 updates in 0.001s
Final edges: 12
Matching size: 8
Maximal: TrueIntegration checklist
- Validate update ordering at your input boundary.
- Persist the update trace if you need reproducibility.
- Assert maximality in staging and benchmark runs.
- Pin the Axiom version and record the selected mode.
- Do not share one matcher instance across concurrent writers.