Graph Segment Algorithms for Graph Neural Network-based Tracking
Installation
pip install graph_segment
Usage: get_tracks
After a GNN has scored the edges of a hit graph, graph segmentation cuts the graph into tracks. All algorithms ("backends") sit behind one function, so switching algorithm means changing one string:
import graph_segment
# edge_index: (2, E) int array, each edge pointing outward (from the hit nearer the
# interaction point), so the graph is acyclic; scores: (E,) edge scores
tracks = graph_segment.get_tracks(num_nodes, edge_index, scores, "cc_bestpred_walk",
cc_cut=0.01, th_min=0.3, th_add=0.8,
min_track_score=0.5, min_track_hits=7)
# {"cc": [[node, ...], ...], "walk": [...]} node indices into the graph
print(list(graph_segment.BACKENDS))
| backend | what it does |
|---|---|
cc |
drop edges with score <= cc_cut; the connected components that are simple paths (no hit with two incoming or two outgoing edges, >= 3 hits) are tracks |
cc_walk |
cc, then walk through the branching components. From each unused hit in topological order, follow the best edge above th_min and branch on every edge above th_add, then keep the longest path |
cc_bestpred_walk |
cc_walk with the best-predecessor rule: step u -> v only if u -> v is v's best edge from an unused hit, so a branch that joins another track's chain cannot take its hits |
cc_junction_removal |
simple chains of >= min_chain_length hits after cc_cut. On the other hits, keep each edge above junction_cut that is the best in-edge of its target and the best out-edge of its source, and take their components as tracks |
- Cuts:
get_trackstakes the cuts of every backend. Each backend uses only its own cuts, so one set of cuts works for all of them, and a misspelled cut name raises an error. - Filters: every backend takes
min_track_score(drop tracks whose mean internal edge score is lower) andmin_track_hits. - Track length: no backend returns a track with fewer than two hits.
- Implementation: the backends are C++ on plain edge arrays (
src/cpp_core/bestpred_walk.cxx), with no Boost and no networkx. - Adding a backend: write
fn(num_nodes, edge_index, scores, cut_a=..., ...) -> {method: tracks}and add it toBACKENDSinsrc/graph_segment/__init__.py. Name each cut as a keyword parameter, not**kwargs:get_trackspasses a backend only the cuts it names.
cc_and_bestpred_walk(...) is still available and returns (cc_tracks, walk_tracks).
Validation: every backend gives the same tracks as the Python implementation in
acorn (acorn.stages.track_building.segmentation). The one exception is that acorn's
plain walk also returns dead-end hits as 1-hit "tracks". tests/test_get_tracks.py makes
this comparison on random graphs when acorn is installed. Run the tests with pytest tests/.
Benchmark: muon collider with BIB
Setup:
- Events: 993 validation events, each with one muon plus ~120k beam-induced-background hits (~72k GNN edges per event). The GNN is acorn's v3 muon-collider model (epoch 154).
- Script:
benchmarks/muon_collider.py. It needs acorn to read the graphs and match tracks. - Matching: acorn's matching with 50% of hits and tracks of >= 5 hits.
- Metrics: eff uses ATLAS matching and eff 2-way two-way matching. fake is the fraction of tracks matched to no particle. dup is the number of extra matched tracks per reconstructed muon.
- Filtered:
min_track_score=0.5,min_track_hits=7. - Time:
get_trackswall time per event with one thread on a Perlmutter CPU node. Loading the graph and matching are excluded.
| backend | cuts | eff | fake | dup | eff 2-way | eff / fake / dup (filtered) | time / event |
|---|---|---|---|---|---|---|---|
cc |
0.01 | 0.000 | 1.000 | - | 0.000 | 0.000 / - / - | 9.6 ms |
cc |
0.9 | 0.189 | 0.041 | 0.000 | 0.178 | 0.183 / 0.005 / 0.000 | 10.2 ms |
cc_walk |
0.01 / 0.3 / 0.8 | 0.989 | 0.306 | 0.017 | 0.983 | 0.985 / 0.027 / 0.005 | 10.7 ms |
cc_bestpred_walk |
0.01 / 0.3 / 0.8 | 0.993 | 0.303 | 0.012 | 0.988 | 0.990 / 0.019 / 0.003 | 10.2 ms |
cc_junction_removal |
0.7 / 0.5 / 3 hits | 0.991 | 0.034 | 0.138 | 0.928 | 0.979 / 0.003 / 0.052 | 16.4 ms |
The physics numbers are identical to acorn's Python backends on the same events. The speed
is not: acorn takes 1.15 s per event for cc and cc_walk, which use networkx, and about
22 ms for its numpy cc_bestpred_walk and cc_junction_removal.
What to take from it:
- Use
cc_bestpred_walkwith the filter. It has the best efficiency with a 2% fake rate. - Plain CC fails with this background. At a loose cut every muon component touches background hits and branches. At a tight cut the muon breaks into pieces.
- Without the filter every walk makes ~30% fakes. These are mostly short 5–6 hit background segments. The length and score filter removes them for < 0.5% efficiency.
- Junction removal splits the muon. Its ATLAS efficiency and fake rate look good, but its dup rate is high and its 2-way efficiency is low. Compare backends on the 2-way efficiency and dup columns too.
Per-event data: https://portal.nersc.gov/cfs/m3443/xju/muon_collider/segmentation_benchmark/graph_segment/
Test
pytest tests/
Developer Guide
Install a Python virtual environment and activate it:
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install cibuildwheel build twine
Then you can run
pipx run cibuildwheel --platform linux
Packing and Uploading
python3 -m build --sdist
twine upload dist/* wheelhouse/*
Note
The code was improved by OpenAI o1Pro model. The execution time was reduced from 403 ms to 190 ms.
Metadata
Release files for graph-segment 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| graph_segment-0.1.0.tar.gz | 18.4 kB | Without provenance | Details for graph_segment-0.1.0.tar.gz |
Built distributions (wheels)
Total release size: 10.0 MB
Release files / graph_segment-0.1.0.tar.gz
| Download URL | graph_segment-0.1.0.tar.gz |
|---|---|
| Size | 18.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e719fc4dcb15958f66d94029e6194d136fd9c769113ac2647c7eeac306d99b2
|
|
BLAKE2b-256 checksum How to use checksums |
bd474ddf0c0232ce8208f948fa17b14496326bd384e5d0621b81307779beaff9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp314-cp314t-musllinux_1_2_x86_64.whl
| Download URL | graph_segment-0.1.0-cp314-cp314t-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
a874dfc97f91eff2c6ca4556b5f0a2155d45e2d72226b3e605f4feafaf53efaf
|
|
BLAKE2b-256 checksum How to use checksums |
8f389147db4fbf90962dede56740d2fd29111cd14d728b15990498c57263a308
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | graph_segment-0.1.0-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 109.9 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
870d50292417e8b17eda81fd49bb951490849e6850ea0f3b85649c5727fc4a0f
|
|
BLAKE2b-256 checksum How to use checksums |
3f5de20d5f686275455b0618069c366a6866d4994739c1a5d49b3059b95d42d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp314-cp314-musllinux_1_2_x86_64.whl
| Download URL | graph_segment-0.1.0-cp314-cp314-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.14 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
a60dd3197726036427705a4170bc565cec2085f6d8a3810b87b154f4cc63ff6f
|
|
BLAKE2b-256 checksum How to use checksums |
34e38d398598f918d03a67c3486096eb3e0bef4685dc2a52dbad2d5b21313de4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | graph_segment-0.1.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 108.3 kB |
| Tags | CPython 3.14 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
c61964d1ecf19a718ea357f9998b760b13bda2f82f3acec33af52ea8fdcadb28
|
|
BLAKE2b-256 checksum How to use checksums |
ce35b1dedd29ee3c73d5e914f003a05215ed95a6e9b34d29286f33b1322226cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
| Download URL | graph_segment-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.13 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
38df9ab879503709e55753045039b74832c9a30f5aad81bd88892a1b3245a2f0
|
|
BLAKE2b-256 checksum How to use checksums |
7f933da88b6d37c99c1fcbde37d4ddabe8a07d680f8f9bdd75ec409e275038ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | graph_segment-0.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 108.3 kB |
| Tags | CPython 3.13 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
935dbfaad2ad9942af3539a3baa9d2fa805ba7e80226e5b68b67898feed0d5ed
|
|
BLAKE2b-256 checksum How to use checksums |
9130ef08228f90c3778fc701ddbd2af0b36355a670da21d0a4bcaa5a33de3cc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
| Download URL | graph_segment-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
f0e2ee19d1539de9e4b8727f868da38f1cf3c1bc46d45aae0d5133499aac6265
|
|
BLAKE2b-256 checksum How to use checksums |
b2d127e3453bab79939257ce0527b80c8ea6384c16b4bff06d2871118646a066
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | graph_segment-0.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 108.3 kB |
| Tags | CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
6da123366ca5334dc78043fbdfcfa720ad848c0174aeca8838deab2838f96300
|
|
BLAKE2b-256 checksum How to use checksums |
eccb448c749281d39d41e8259f689afe1050fb36acff516da2c580990304de85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
| Download URL | graph_segment-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
0073ee4769112b2250e4348342956c7e18e43ac677c66d6b15dd2cc42659092b
|
|
BLAKE2b-256 checksum How to use checksums |
7d184438943aa008a3ed90b7836b5dc291e682d867651d120d4402a819343607
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | graph_segment-0.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 107.6 kB |
| Tags | CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
3c1f11045eb27a7c477eeb2b5d6538ea3a4b8bcb401f8924346638913aedadcf
|
|
BLAKE2b-256 checksum How to use checksums |
c08b8e335aad43adc54baa66d23bbc479db1b739d3b6bef415eed2d9de86a73c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
| Download URL | graph_segment-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
24d6fecd37b0e2a01042ac9567e65871157ab45ce2701ab5021056dd05cbe414
|
|
BLAKE2b-256 checksum How to use checksums |
181f0cc73647cb8263eb0efb1d6396ac0b09ab837dfb29ff94f073153aea3e95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | graph_segment-0.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 108.0 kB |
| Tags | CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
3690e7dbb0554f3308eeda437fd3de62facf73e22614c000dc3cac3f1550a810
|
|
BLAKE2b-256 checksum How to use checksums |
08fc01592aec2bfdd2d7d2225526c631d638eee2b1cf791f7a3be93a9f945de0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp39-cp39-musllinux_1_2_x86_64.whl
| Download URL | graph_segment-0.1.0-cp39-cp39-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
e8722d29515b0b00eda44c64d5eb5bc8c37bda739f6e86376c5ce5649a00d421
|
|
BLAKE2b-256 checksum How to use checksums |
4d32d988717e3841122ff30707eef63eec822220de69f8703f04b9af395b9f69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | graph_segment-0.1.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 107.6 kB |
| Tags | CPython 3.9 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
0a0627cf0f5a40769b8e90137f2e5f2bfd1a36dcad2c2b5fe605716a13b7d7b9
|
|
BLAKE2b-256 checksum How to use checksums |
928d6d8e1c51820c18e6fcc07a1a695d948f3b0ca9281499eba9e1a5f5da7d95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp38-cp38-musllinux_1_2_x86_64.whl
| Download URL | graph_segment-0.1.0-cp38-cp38-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.8 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
bdda1bf9e21bd9aa6d27308c3141fc8e48544f3cdf3e4db1d0c1e5dc775dcb56
|
|
BLAKE2b-256 checksum How to use checksums |
54b4aadf761f7cf4d888fe10750f264ae9fa1808f95fde489e6cd573835d3e20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / graph_segment-0.1.0-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | graph_segment-0.1.0-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 106.4 kB |
| Tags | CPython 3.8 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
57b2e4ebe1aeefe77f0db87b6cb362dac0b6a9e6e56270c446b280ab25e9c736
|
|
BLAKE2b-256 checksum How to use checksums |
b61c6ebbf158737d4a583972ccd08b60023f1694899c4a7ca8f50496b2fc1a20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for graph-segment 0.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.