Manuscript Offprint
arXiv:2609.31152KnottedGraph: Scalable knotted-graph topology for scientific and mathematical discovery
Hakan Akgün , Xianquan Yan , Kehan Liu , Zhaoyun Chen , Ching Hua Lee
Department of Physics, National University of Singapore, Singapore 117551, Singapore
Department of Computer Science, National University of Singapore, Singapore 117417, Singapore
Scientific data span heterogeneous structures, including coordinates, networks, surfaces, volumes and fields, yet their topology can be quantified within a common framework through graph connectivity, cycle structure, genus and spatial embedding. Graph- and homology-based summaries do not determine spatial embedding, while standard knot and link polynomials require extensions to accommodate branching graphs. Here, we introduce KnottedGraph, a computational framework that converts such scientific representations to knotted graphs that retain graph connectivity and spatial embedding together. It constructs projected diagrams and PD codes, enabling various topological analyses, including Yamada-polynomial evaluation for topological classification. For scalable exact evaluation, it combines partial resolutions that leave the same unresolved connections and optimizes their processing order; the resulting algorithm is verified against published topological invariants of knotted graphs with up to 500 crossings. This scalability enables us to introduce an LLM-assisted mathematical-discovery methodology, in which computational topological data generated across knotted-graph families are used to identify candidate closed-form formulas. With this approach, we identify analytical Yamada-polynomials for generic graph motif families exhibiting Abelian and non-Abelian word sequences. Together, these scalable capabilities make knotted-graph topology computationally accessible across scientific domains, enabling large-scale classification and introducing a route from topological data to LLM-assisted AI4Math discovery.
Introduction
Many systems in biology, materials science and physics are governed by graph connectivity and spatial embedding. Examples include biomolecular backbones [1, 2] (Fig. 1a), vascular [3] and neuronal networks [4] (Fig. 1b), polymers [5, 6] (Fig. 1c), engineered spatial networks [7, 8] (Fig. 1d), Hamiltonian-derived geometries [9–14] (Fig. 1e) and vector flow curves [14, 15] (Fig. 1g). Their physical origins differ, but the computational question is the same when underlying topology matters: the representation must retain graph connectivity and spatial embedding, i.e., edge over/undercrossing information.
Graph connectivity and homological quantities capture abstract topological structure [16–18], but do not in general determine the ambient-isotopy class of a spatial graph [19, 20]. Classical knot and link polynomials are sensitive to embedding, but their standard definitions apply to knots and links [21–24], and extensions are required to accommodate branching graph connectivity [25]. On the other hand, knotted graphs retain both types of information, graph connectivity and spatial embedding, in the same object and can be distinguished using their associated invariants [19, 20, 25], one of the most prominent being the Yamada polynomial [25, 26].
Previous work has established the usefulness of knotted-graph descriptions and invariants in polymer systems, engineering design and condensed-matter physics [5, 8, 14]. Extending these analyses across heterogeneous scientific data requires a common knotted-graph representation and scalable invariant evaluation. Explicit curves and networks can enter this representation directly, whereas surfaces and volumes require construction of the corresponding spatial graph while preserving graph connectivity and three-dimensional edge geometry, including candidate graph spines when a handlebody–spine description is appropriate [27, 28]. The resulting knotted graph can then be projected to a planar diagram retaining graph vertices, projection crossings and edge over/undercrossing information [8, 19, 20], converted to PD encoding [6, 29], and evaluated through the Yamada polynomial [25, 26]. Here, we introduce a computational framework that integrates these stages and makes the invariant calculation scalable enough for repeated analysis across derived datasets, parameter sweeps and mathematically generated graph families, while supporting additional analyses including vector-flow characterization [14], repulsive-curve preconditioning [30] and parameter-space analysis [14].
For embedding-sensitive topological analysis at scale, one important algorithmic bottleneck is Yamada evaluation [25, 26]. Our algorithm combines resolutions whenever they leave the same unresolved connections and orders local operations to keep the number of simultaneously unresolved arc ends small. On the structured published families in Refs. [32, 33], this allows us to reproduce the known formulas of spatial graphs with up to 500 crossings. This efficiency enables repeated invariant evaluation across scientific parameter spaces and algorithmically generated graph families, where exact topological invariants can also serve as data for mathematical discovery.
Recent advances in AI-assisted mathematics have rapidly expanded evaluation-guided search, mathematical construction and machine-verifiable reasoning across increasingly challenging research settings [34–39]. In structured spatial-graph families, Yamada-polynomial formulas are traditionally derived analytically from the family construction, for example using recurrence or transfer-matrix methods [32, 33, 40]. Such derivations are generally family-specific and are not automatically inferred from computed invariant data. Here, we introduce an LLM-assisted mathematical-discovery methodology in which Yamada values are generated computationally, used to identify candidate family relations, converted to explicit symbolic forms and tested on additional family members. Our framework thereby extends this emerging direction to exact topological-invariant data and the reconstruction of interpretable algebraic structure across knotted-graph families.
More broadly, the framework opens several directions beyond the results developed here: embedding-sensitive analysis across scientific parameter spaces; extension from handlebody
Following the terminology of our companion work [14], we use knotted graph and spatial graph synonymously throughout this work, with spatial graph retained where conventional mathematical terminology is useful.
(a) Biomolecular backbones
PDB / mmCIF
(b) Neural & vascular networks
SWC / NPY / NPZ

(c) Polymer structures
GRO / LAMMPS dump
(d) Engineering spatial networks
CSV / JSON / GraphML

(e) Hamiltonian-derived spatial graphs
Hamiltonian / JSON / NPZ

(f) Surface & volume skeletons
OBJ / OFF / PLY / STL
VTK / VTP / NPY / NPZ
(g) Oriented fields & flows
NPY / NPZ
(h) Mathematical spatial graphs
CSV / JSON / GraphML


Heterogeneous
Scientific
Inputs
Knotted/
Spatial
Graphs
Projection/PD
Representations
Topological
Analysis
Fig. 1 | Heterogeneous scientific geometry is brought to one knotted-graph representation. (a) Biomolecular backbones, represented by the Cα trace of chain A of 1IPA [31], from the RCSB Protein Data Bank [1, 2]; (b) neuronal and vascular morphologies [3, 4]; (c) polymer configurations [5, 6]; (d) engineered node–edge networks [7, 8]; (e) Hamiltonian-derived level-set or occupied-region geometry [9–11, 14]; (f) a volumetric regular-neighborhood input and a candidate graph spine [27, 28]; (g) vector field curves [15]; and (h) mathematical spatial graphs [19, 20]. The bottom workflow summarizes the common analysis path from heterogeneous scientific inputs to knotted/spatial graphs, projection/PD representations and topological analysis. Format labels in panels (b), (d) and (h) describe source data, not necessarily direct adapter inputs: SWC, GraphML and arbitrary graph-JSON records are converted externally to paired node–edge CSV before use (Supplementary Table 1).
spines to more general volumetric topologies; implementation of additional knot, link and spatial-graph invariants, including the Alexander, Jones and HOMFLY–PT polynomials [21–23]; and LLM-assisted mathematical discovery across broader structured families, including braid words, tangles, satellite operations and other recursive constructions [40–43]. Together, these directions connect scalable embedding-sensitive topological analysis with a general route from exact invariant data to automated mathematical formula discovery.
A common knotted-graph representation for scientific geometry
We use the knotted graph as the common representation through which heterogeneous scientific geometries become directly comparable (Fig. 1; Supplementary Fig. 1). For inputs in which this graph is not given explicitly, a central contribution is knotted-graph construction: when a handlebody–spine representation is appropriate (Supplementary Note 1.B), surface or volumetric geometry is reduced to a one-dimensional skeleton [44] and converted to a knotted graph through multiscale junction identification and topology selection [45], as shown in Fig. 2a and Supplementary Fig. 2. The resulting graph retains connectivity and three-dimensional edge geometry for projection and PD construction (Supplementary Note 2), invariant evaluation (Supplementary Note 3), geometric and vector-flow analysis, parameter-space analysis (Supplementary Note 5) and geometric preconditioning (Supplementary Note 6), as summarized in Fig. 2b–f.
For surface or volumetric inputs representing a handlebody or handlebody-link, the Yamada-invariant route is
where is the volumetric region, the resulting candidate graph spine, PD the corresponding PD code and the normalized Yamada polynomial. Because these stages are modular, applications can enter Eq. (1) at the representation appropriate to their input and use only the required downstream operations.
The first transformation in Eq. (1) is nontrivial because a finite-resolution skeleton does not uniquely identify the physical junctions of the underlying graph. A thick junction can thin to several nearby branch voxels, while distinct physical junctions can also lie close in space. We therefore construct candidate graphs from the same skeleton over neighbouring junction scales,
where is the one-voxel-wide skeleton and h controls the local junction region. When a topology recurs across
(a) Knotted/Spatial Graph Construction

(b)
Projection / PD-Code Analysis

(d)
Vector Flow Analysis
(c)
Invariant Calculation


(e)
Parameter Space Analysis
(f)
Repulsive Curves

50SQ ZP3 ZP-N

Fig. 2 | One knotted-graph representation supports knotted-graph construction, invariant evaluation and repeated scientific analysis. (a) Volumetric geometry is processed into a candidate graph spine; (b) the embedding is projected to a regular diagram and PD code; (c) the Yamada polynomial is evaluated; (d) vector flow analysis and graph-level orientation remain attached to the knotted graph [14]; (e) repeated calculations organize parameter-dependent graph outputs [14]; and (f) optional geometric preconditioning can regularize difficult embeddings before projection [30].
the tested scales, this cross-scale recurrence determines the selected graph; if no valid topology recurs, the direct zero-radius trace is retained. For large digital skeletons, sparse voxel connectivity is constructed once and reused across candidate scales, with three-dimensional edge coordinates generated only for the selected scale while preserving the same cross-scale consistency criterion (Supplementary Note 1.C).
The next transformation projects a spatial embedding to a regular diagram [19, 20]. For a sampled viewing direction , let
where is the number of projection crossings. Constructing the complete PD code for every sampled view is unnecessary. Instead, KnottedGraph first compares the crossing counts and constructs complete diagrams only for the best candidates (Supplementary Note 2.A; Supplementary Fig. 4a–c). When a crossing is found, its position along both parent graph edges is also recorded in the same geometric search (Supplementary Note 2.B). These positions are the cut locations required by PD construction, so the same crossing does not need to be found again (Supplementary Note 2.C; Supplementary Fig. 3).
The final transformation is combinatorially more demanding. At each crossing, the raw Yamada polynomial obeys the three-term local relation [26],
where and are the two smoothings and replaces the crossing by a graph vertex. For a complete resolution state s, let be the resulting crossing-free graph and let and count the two smoothing choices. This is the standard Yamada state-sum construction [26, 33]; the diagram polynomial can be written as
For a crossing-free state, Yamada’s graph polynomial is a specialization of the Negami graph polynomial [26, 33, 46]; equivalently, in the included-edge form used by the library,
Here and are the vertices and edges of , and is the cycle rank of the spanning subgraph and is its number of connected components. Thus repeated application of Eq. (4) reduces the mathematical problem to crossing-free graph contributions. Under the diagram moves needed to pass from regular to ambient isotopy, the raw Yamada polynomial can acquire a monomial factor [25, 26]. To fix that ambiguity consistently in the library, for a nonzero raw polynomial we write and use the convention
with an evaluated zero kept as zero. For subcubic spatial graphs, this removes the remaining monomial ambiguity so that is independent of the accepted regular projection and provides an ambient-isotopy invariant [25, 26] (Supplementary Note 3).
Since each crossing has the three local resolutions in Eq. (4), a direct expansion of a diagram with crossings contains
complete resolution assignments (Supplementary Note 3.A; Supplementary Fig. 5). Although Eq. (5) sums over all of these resolutions, many partial resolution histories become equivalent before completion when they leave the same unresolved connectivity. Our algorithm therefore stores one state for each such connectivity and combines the corresponding Laurent-polynomial contributions.
The cost of this compressed calculation depends on and on how many arc ends remain unresolved at the same time. KnottedGraph chooses a processing order that keeps this number small and, for sufficiently difficult diagrams, tests
(b)

(c)
(d)


(e)
(f)

V[12,0,6];V[5,11,12];X[1,10,0,11];X[9,2,10,1];X[3,8,2,9];X[7,4,8,3];X[5,6,4,7]

V[2,0,6,4];V[10,8,3,1];
V[7,5,11,9];X[9,11,8,10]
];X[0,2,1,3];X[5,7,4,6]

(g)
V[10,8,6,4,2,0];V[5,11,9,3,1,7];X[9,11,8,10];X[1,3,0,2];X[5,7,4,6]
(h)
(i)



Fig. 3 | Exact Yamada evaluation across published closed-form spatial-graph families. Columns show the family [32], the family and the family [33]. (a,d) Representative embedding and corresponding projected diagram and PD code; (b,e) representative embedding and corresponding projected diagram and PD code; (c,f) representative embedding and corresponding projected diagram and PD code. (g–i) Invariant-evaluation time as a function of the corresponding family parameter. At 500 crossings, the corresponding KnottedGraph evaluation times are approximately 0.12 s, 2.4 s and 5.0 s, with each result agreeing with the corresponding published reference polynomial. External-software timings [6] are shown only where both implementations reproduce the same published reference polynomial; the Topoly series terminates once no further passing result is obtained under the benchmark protocol.
alternative starting choices. Vertices with many incident edges are represented internally by equivalent smaller connection steps, further reducing the number of unresolved arc ends. Because the number of simultaneously unresolved arc ends also depends on the projection, the projection with the fewest crossings need not give the fastest Yamada evaluation. The state-combination and ordering procedures are developed in Supplementary Note 3.C, and the projection-refinement procedure in Supplementary Note 2.A. Thus, across the three transformations in Eq. (1), KnottedGraph retains only the information required by the next stage, avoids constructing equivalent intermediate objects and uses the structure of the downstream calculation when choosing among alternative representations.
Independent tests of knotted-graph construction, projection and topological invariant evaluation
Next, we validate the three steps individually: knotted graph construction in Supplementary Note 4.B, projection and algebraic consistency in Supplementary Note 4.A, with the corresponding methods detailed in Supplementary Note 1.C, Supplementary Note 2 and Supplementary Note 3, respectively.
Knotted-graph construction is tested through an inverse benchmark. Known knotted graphs are thickened and voxelized, passed through the pipeline, and then compared with their generating seeds (Supplementary Fig. 6). The benchmark independently checks the topology of the voxelized input, the graph connectivity and cycle structure of the resulting graph, and the normalized Yamada polynomials of the seed and output. Across all 4,400 curated constructions, every case passes the stated input and graph-level recovery checks, and all 4,400 seed–output normalized Yamada polynomials agree, showing consistent recovery of the intended cycle structure and normalized Yamada invariant within the tested handlebody regime and numerical conditions.
Then projection and invariant calculations are tested. Multiple accepted generic views are generated for fixed subcubic spatial graphs. Although different views can produce different crossing numbers, arc labels and PD codes, all accepted regular projections of the same tested graph give the same normalized Yamada polynomial, as required by its ambient-
| Family | KnottedGraph (s) | Topoly (s) | Runtime ratio |
|---|---|---|---|
| 0.0125 | 0.4758 | 38× | |
| 0.0159 | 3.1880 | 200× | |
| 0.0162 | 15.4393 | 960× |
Table 1 | External-software timing comparison at seven crossings. For each family, the two timings correspond to the same PD input and both implementations reproduce the corresponding published reference polynomial [32, 33] where the runtime ratio is .
isotopy invariance in the subcubic setting [25, 26]. Planar reference graphs also agree with independently evaluated crossing-free graph polynomials. The Yamada calculation is then tested against graph-polynomial identities, crossing and mirroring relations, and published closed-form Yamada families [26, 32, 33]. It reproduces the tested tree, cycle, bouquet and theta relations [26, 33], together with planar and other published cubic-graph values [32]. Together, these tests verify projection consistency for the tested subcubic embeddings and the Yamada calculation against independent mathematical results. Stage-wise timing distributions for these steps and their subprocesses are reported in Supplementary Fig. 7.
Scalable Yamada polynomial evaluation across knotted graphs
Having established the representation and its validation, we next test whether spatial-graph invariants can be evaluated at a scale suitable for repeated scientific and mathematical analysis. The defining local relation and full state sum are given in Eqs. (4) and (5), and the formal resolution-space growth in Eq. (8); the connectivity compression above avoids explicit construction of that complete tree.
The structured-family test uses the three published families shown in Fig. 3 [32, 33]. The first column (Fig. 3a,d,g) shows the family; the second (Fig. 3b,e,h) shows the edge-replaced cycle family , where each edge of the cycle is replaced by the spatial part ; and the third (Fig. 3c,f,i) shows the corresponding edge-replaced theta family [33]. Across these families, KnottedGraph reproduces the published formulas of knotted graphs up to 500 crossings. At 500 crossings, the measured evaluation times are 0.12 s, 2.4 s and 5.0 s, respectively, with each result verified against the corresponding published formulas [32, 33] displayed in Supplementary Note 4.A.
The invariant-evaluation scaling is shown in Fig. 3g–i. Across the tested structured families, the algorithmic optimizations produce subexponential empirical runtime growth over the benchmarked range, enabling exact calculations through 500 crossings. In comparison, the external software implementation [6] exhibits approximately exponential growth over the accessible range, making direct comparison impractical at higher crossing numbers. The execution times at seven crossings are reported in Table 1.
LLM-assisted mathematical discovery from exact knotted-graph data
Recent advances in AI-assisted mathematics have shown how LLM-guided search, computational evaluation and machine-verifiable reasoning can expose mathematical structure across increasingly challenging problem settings [34, 36–38]. Relations across parameterized mathematical families are con- ventionally identified and derived through human-guided analysis of the family construction and its computed examples [32, 33, 40]. Previous Yamada-polynomial formulas for structured spatial-graph families have likewise been obtained from analytically specified recurrences, edge-replacement relations or transfer constructions [32, 33, 40]. The scalability established above allows KnottedGraph to reverse this direction of investigation: exact Yamada-polynomial data can be generated before a family law is known and then used with LLM assistance to identify candidate recurrences, closed forms and transfer structures. We apply this strategy below to repeated-motif families with both commuting and noncommuting composition laws.
The discovery and validation procedure is summarized in Fig. 4a. A parameterized graph family is first evaluated with KnottedGraph to generate exact Yamada polynomials, which are then blindly divided into a discovery set and a held-out test set . Only is supplied during LLM-assisted candidate generation. A retained proposal is converted to an explicit symbolic expression or operator representation before the members in are evaluated and compared with its predictions. Candidate generation and testing are therefore separated by construction; agreement on provides a finite out-of-sample test. The full protocol and completed evaluation plans are detailed in Supplementary Note 7.A.
We first apply this workflow to the three homogeneous motif families in Fig. 4b–j. For each family, the first two panels show the m = 1 and m = 2 members together with normalized Yamada polynomials computed directly by KnottedGraph, while the third shows the corresponding general-m relation obtained through LLM-assisted candidate generation and symbolic reconstruction. To write these expressions compactly, we define
In each case, the inferred general relation agrees with the independently evaluated family members used for verification.
The three candidate formulas have different coefficients but share the same algebraic structure: each is reproduced by three transfer channels, with a diagonal transfer operator associated with the repeated motif. The and polynomials are direct evaluations, while the general- expressions are the corresponding candidate analytical formulas proposed by LLM, revealing a common three-channel mathematical structure across three distinct repeated-motif families. Their matrices and algebraic expansions are given in Supplementary Note 7.B.
The mixed construction in Fig. 4k then tests how these reconstructed motif transfers compose when different motifs occur within the same knotted-graph family. Let
where n records the motif multiplicities. Because the reconstructed local transfer operators commute, the proposed invariant is independent of motif order and therefore factors through the abelianization of the motif word,

Abstract graph-family
Compute Yamada with KnottedGraph
| i | Yamada |
|---|---|
| 1 | |
| 2 | |
Blind data split
Learning set D
Test set T
LLM proposes a closed-form formula
Blind validation
m=1
(b)
Cross-Linked
Family

m=2
(c)

(d)
general m

(e)
Lower-Paired
Family

(g)


Two-Sided
Family

(i)

(j)

(k)
Abelian
Family

(1)
Non-Abelian
Family
Fig. 4 | Exact Yamada-polynomial data are used to infer and test commuting and order-sensitive noncommuting family laws. (a) For a parameterized graph family, exact Yamada polynomials are first generated with KnottedGraph and blindly divided into a discovery set and a held-out test set . Only is supplied during LLM-assisted candidate generation; a retained relation is converted to a fixed symbolic formula or transfer representation before the members of are evaluated. (b–d) Cross-linked family ; (e–g) lower-paired family ; and (h–j) two-sided family , shown for , and the corresponding candidate general- law. The three families exhibit a common three-channel transfer structure. (k) Combining the three motifs within one family gives commuting transfer operators, so the candidate invariant for an arbitrary motif word depends only on the motif multiplicities and is unchanged by reordering. (l) In contrast, on a fixed 8-vertex, 12-edge cubic multigraph carrying ordered pure-braid blocks and , words with identical block multiplicities can yield different normalized Yamada polynomials. Finite exact Yamada data reconstruct a 15-state noncommuting transfer representation whose generators obey a common cubic relation, retaining braid-word order while reducing repeated runs to three spectral channels.
This gives a single closed-form Yamada-polynomial for arbitrary mixed words in the three motifs: once the motif multiplicities are fixed, reordering the word leaves the predicted invariant unchanged. The resulting count-dependent candidate expression is displayed in Fig. 4k, with its full symbolic derivation and independent verification given in Supplementary Note 7.B.
The fixed-graph pure-braid family in Fig. 4l provides the complementary order-sensitive case and a stronger departure from count-based family descriptions. Here the underlying 8-vertex, 12-edge cubic multigraph remains fixed, while a distinguished three-strand region carries an ordered word with and , using the standard Artin braid generators [41]. The abstract graph is therefore unchanged as the word varies; only the spatial embedding of the braid region is modified. Already at length three, words with identical motif counts can have different normalized Yamada polynomials,
Thus motif counts determine the proposed invariant for the commuting mixed family, but not for the pure-braid family: the ordering of the local braid blocks remains visible to the invariant. A length-five example of this order-dependent braid construction is shown in Supplementary Fig. 10.
To reconstruct this order dependence directly from finite exact data, we use a symbolic Hankel-based realization with finite-rank realization methods [47, 48]. A rank-fifteen finite Hankel block gives 15-dimensional transfer operators and . This dimension is consistent with the three-strand Yamada-algebra structure [49], showing that the LLM-proposed transfer description, once reconstructed exactly from finite Yamada-polynomial data, recovers a structure compatible with the known skein-algebraic setting. The reconstructed operators satisfy
making the noncommutativity explicit. Each operator also obeys the common cubic relation
where . Since this cubic annihilating polynomial has three distinct roots, the standard spectral decomposition gives
where are the corresponding spectral projectors.
Writing an arbitrary braid word as its ordered maximal runs, with , gives the candidate analytical family relation displayed in Fig. 41. Each of the two transfer operators, and , contributes the same three scalar spectral powers, while the corresponding projectors remain ordered according to the braid word, thereby compressing arbitrarily long repeated words. The boundary vectors and are reconstructed from the Hankel representation, and is the minimum Laurent degree of the corresponding raw Yamada polynomial used for normalization. The Hankel-based realization, 15-dimensional linear representation, projector construction, ordered-word formula and short- and long-word verification are given in Supplementary Note 7.C. These relations are supported by direct evaluation on all 459 mixed-family words, 255 distinct short pure-braid words and 20 held-out pure-braid words of lengths 101, 125, 150 and 200.
Taken together, the commuting mixed-family law above extends Yamada family formulas to arbitrary motif words whose invariant factors through motif multiplicities. More distinctively, the fixed-graph pure-braid construction provides, to our knowledge, the first Yamada-polynomial family law for arbitrary ordered words of noncommuting local motifs: the underlying cubic multigraph remains fixed, while words with identical braid-block multiplicities can yield different invariants. Finite exact Yamada-polynomial data further reconstruct the corresponding 15-state noncommuting transfer representation and its cubic generator relations. This establishes a more general data-to-algebra methodology in which exact topological invariants can be used to infer candidate composition laws for entire parameterized graph families without prescribing their family-specific recurrence, transfer structure or closed form in advance. Coupled with LLM-assisted candidate generation, this provides an AI4Math route from exact invariant data to interpretable mathematical structure that can in principle be applied across broader motif-, word- and recursively generated graph families for which analytical formulas are not yet known.
Discussion
Overall, KnottedGraph establishes a unified, efficient computational route from three-dimensional scientific geometry to embedding-sensitive topological analysis, connecting problems across biology, materials science, engineering, physics and mathematics. By integrating knotted-graph construction, projection and exact invariant evaluation, the framework makes spatial topology accessible for systematic analysis across heterogeneous scientific structures, parameter spaces and generated graph families. The scalability of the invariant calculation also enables a different use of computational topology: exact spatial-graph invariants can serve as structured data for mathematical discovery. Here, LLM-assisted candidate generation identifies closed forms and transfer structures from computed Yamada-polynomial data, followed by explicit symbolic reconstruction and additional exact tests. The resulting commuting and noncommuting transfer descriptions capture count-dependent and order-sensitive family laws, respectively. Together, these capabilities connect large-scale embedding-sensitive topological analysis with a route from exact topological data to automated mathematical formula discovery.
Several computational and mathematical directions follow from the present framework. In condensed-matter and materials settings, Hamiltonian parameters, energy thresholds, strain [50], pressure [51] or composition [52] can generate families of three-dimensional structures whose embedding-sensitive topology evolves across parameter space [14]. Such physical settings also motivate extending the framework beyond handlebodies to more general volumetric topologies. A handlebody admits a graph-spine description, whereas compression bodies [53] can contain distinguished boundary components with direct physical relevance [14], together with attachment and nesting information that cannot in general be encoded by a single graph. This motivates extending the same automated computational framework to spatial-graph invariants with set-valued constructions, such as the Yamada set [14].
Related parameter-dependent analyses can also be developed for conformational ensembles of biomolecules [2] and polymers [5], evolving vascular [3] or neuronal morphologies [4], and families of engineered three-dimensional networks [7, 8], whenever changes in spatial embedding carry information beyond abstract graph connectivity. Repeated application of the same knotted-graph and invariant interfaces can then organize these systems into topological maps, providing a basis for identifying topological transitions, comparing structural families and incorporating embedding-sensitive topology into scientific classification and design.
Further implementations of knot, link and spatial-graph invariants could additionally provide complementary topological classifications and independent exact datasets for mathematical discovery, including the Alexander [21], Jones [22] and HOMFLY–PT [23] polynomials, allowing algebraic structures reconstructed from different invariants to be compared. Braid words [41], tangles [42], satellite operations [43] and other recursive constructions [40] likewise provide broader family classes in which the same LLM-assisted discovery strategy could be used to identify candidate recurrences, transfer representations and composition laws from exact invariant data, and to probe possible mathematical connections between these different constructions.
Code and data availability
Source code, documentation, workflows and data supporting this work are available at https://github.com/HakanAkgn/KnottedGraph, with additional reproducibility and software-architecture details provided in Supplementary Note 8.
Acknowledgements
We thank Henrik Schumacher and Keenan Crane for helpful guidance on the repulsive-curve framework and the associated https://github.com/HenrikSchumacher/Repulsor repository. During the preparation of this manuscript, the authors used OpenAI's GPT-5.6 Sol for language refinement, code optimization and candidate generation in the LLM-assisted mathematical discovery from exact knotted-graph data. All calculations, validation and scientific interpretations remain the responsibility of the authors.
References
[1] Burley, S. K., Berman, H. M., Bhikadiya, C. et al. RCSB Protein Data Bank: biological macromolecular structures enabling research and education in fundamental biology, biomedicine, biotechnology and energy. Nucleic Acids Research 47, D464–D474 (2019).
[2] Yeates, T. O., Norcross, T. S. & King, N. P. Knotted and topologically complex proteins as models for studying folding and stability. Current Opinion in Chemical Biology 11, 595–603 (2007).
[3] Aylward, S. R., Jomier, J., Vivert, C., LeDigarcher, V. & Bullitt, E. Spatial graphs for intra-cranial vascular network characterization, generation, and discrimination. In Medical Image Computing and Computer-Assisted Intervention – MICCAI 2005, vol. 3749, 59–66 (Springer, 2005).
[4] Cuntz, H., Forstner, F., Borst, A. & Häusser, M. One rule to grow them all: A general theory of neuronal branching and its practical application. PLoS Computational Biology 6, e1000877 (2010).
[5] Deguchi, T. & Uehara, E. Statistical and dynamical properties of topological polymers with graphs and ring polymers with knots. Polymers 9, 252 (2017).
[6] Dabrowski-Tumanski, P., Rubach, P., Niemyska, W., Gren, B. A. & Sulkowska, J. I. Topoly: Python package to analyze topology of polymers. Briefings in Bioinformatics 22, bbaa196 (2021).
[7] Shai, O. & Preiss, K. Graph theory representations of engineering systems and their embedded knowledge. Artificial Intelligence in Engineering 13, 273–285 (1999).
[8] Peddada, S. R. T. et al. Enumeration and identification of unique 3d spatial topologies of interconnected engineering systems using spatial graphs. Journal of Mechanical Design
145, 101708 (2023). 2107.13724.
[9] Fang, C., Weng, H., Dai, X. & Fang, Z. Topological nodal line semimetals. Chinese Physics B 25, 117106 (2016).
[10] Bi, R., Yan, Z., Lu, L. & Wang, Z. Nodal-knot semimetals. Physical Review B 96, 201305 (2017).
[11] Lee, C. H. et al. Imaging nodal knots in momentum space through topolectrical circuits. Nature Communications 11, 4385 (2020).
[12] Yan, X., Akgün, H., Kawaguchi, K., Loh, N. D. & Lee, C. H. HSG-12M: A large-scale benchmark of spatial multigraphs from the energy spectra of non-hermitian crystals. In The Fourteenth International Conference on Learning Representations (2026). URL https://arxiv.org/abs/2506.08618v5.2506.08618v5.
[13] Yan, X., Akgün, H., Kawaguchi, K., Loh, N. D. & Lee, C. H. Classifying the graph topology of non-hermitian energy spectra with graph transformer. In Second Workshop on XAI4Science: From Understanding Model Behavior to Discovering New Scientific Knowledge (2026). URL https://openreview.net/forum?id=sH1WzXPzEr.
[14] Akgün, H., Yan, X. & Lee, C. H. Topological classification through knotted graphs: Fermi surface dispersions and lifshitz transitions (2026). URL https://arxiv.org/abs/2609.13390. 2609.13390.
[15] Helman, J. & Hesselink, L. Representation and display of vector field topology in fluid flow data sets. Computer 22, 27–36 (1989).
[16] Carlsson, G. Topology and data. Bulletin of the American mathematical society 46, 255–308 (2009).
[17] Edelsbrunner, H. & Harer, J. Persistent homology—a survey. In Surveys on Discrete and Computational Geometry: Twenty Years Later, vol. 453 of Contemporary Mathematics, 257–282 (American Mathematical Society, 2008).
[18] Su, Z. et al. Topological data analysis and topological deep learning beyond persistent homology: a review. Artificial Intelligence Review 59, 58 (2026).
[19] Kauffman, L. H. Invariants of graphs in three-space. Transactions of the American Mathematical Society 311, 697–710 (1989).
[20] Flapan, E., Mattman, T. W., Mellor, B., Naimi, R. & Nikkuni, R. Recent developments in spatial graph theory. In Knots, Links, Spatial Graphs, and Algebraic Invariants, vol. 689 of Contemporary Mathematics, 81–102 (American Mathematical Society, 2017).
[21] Alexander, J. W. Topological invariants of knots and links. Transactions of the American Mathematical Society 30, 275–306 (1928).
[22] Jones, V. F. R. A polynomial invariant for knots via von neumann algebras. Bulletin of the American Mathematical Society 12, 103–111 (1985).
[23] Freyd, P. et al. A new polynomial invariant of knots and links. Bulletin of the American Mathematical Society 12, 239–246 (1985).
[24] Rolfsen, D. Knots and links, vol. 346 of AMS Chelsea Publishing (American Mathematical Society, 2003).
[25] Mellor, B. Invariants of Spatial Graphs (2018). 1812.08885.
[26] Yamada, S. An invariant of spatial graphs. Journal of Graph Theory 13, 537–551 (1989).
[27] Ishii, A. Moves and invariants for knotted handlebodies. Algebraic & Geometric Topology 8, 1403–1418 (2008).
[28] Ishii, A. & Iwakiri, M. Quandle cocycle invariants for spatial graphs and knotted handlebodies. Canadian Journal of Mathematics 64, 102–122 (2012).
[29] Mastin, M. Links and planar diagram codes. Journal of Knot Theory and Its Ramifications 24, 1550016 (2015).
[30] Yu, C., Schumacher, H. & Crane, K. Repulsive curves. ACM Transactions on Graphics 40, 10:1–10:21 (2021). 2006.07859.
[31] Nureki, O. et al. An enzyme with a deep trefoil knot for the active-site architecture. Acta Crystallographica Section D: Biological Crystallography 58, 1129–1137 (2002).
[32] Vesnin, A. Y. & Dobrynin, A. A. Yamada polynomial for graphs embedded knottedly in a three-dimensional space. In Skorobogatov, V. A. (ed.) Graph Theory and Applications, vol. 155 of Vychislitel'nye Sistemy, 37–86 (Institute of Mathematics, Siberian Branch of the Russian Academy of Sciences,
Novosibirsk, 1996). In Russian.
[33] Li, M., Lei, F., Li, F. & Vesnin, A. The yamada polynomial of spatial graphs obtained by edge replacements. Journal of Knot Theory and Its Ramifications 27, 1842004 (2018). 1801.09075.
[34] Romera-Paredes, B., Barekatain, M., Novikov, A. et al. Mathematical discoveries from program search with large language models. Nature 625, 468–475 (2024).
[35] Yan, X. Automated metric discovery: Navigating quantum geometry with symbolic regression. In AI4X 2025 International Conference (2025). URL https://openreview.net/forum?id=E0fa4FXUsW.
[36] Novikov, A. et al. Alphaevolve: A coding agent for scientific and algorithmic discovery (2025). 2506.13131.
[37] Georgiev, B., Gómez-Serrano, J., Tao, T. & Wagner, A. Z. Mathematical exploration and discovery at scale (2025). 2511.02864.
[38] Hubert, T., Mehta, R., Sartran, L. et al. Olympiad-level formal mathematical reasoning with reinforcement learning. Nature 651, 607–613 (2026).
[39] Burtsev, M., He, Y.-H., Sobko, E., Bhattacharya, A. & Graepel, T. How AI is reshaping discovery in maths and physics. Nature 654, 324–326 (2026). URL https://www.nature.com/articles/d41586-026-01820-1.
[40] Lundström, T. Combinatorial Symmetries in Knot Theory: Yamada Polynomials from Transfer-Matrix Methods. Master's thesis, University of Helsinki (2022). URL https://hdl.handle.net/10138/339220.
[41] Birman, J. S. Braids, Links, and Mapping Class Groups, vol. 82 of Annals of Mathematics Studies (Princeton University Press, Princeton, NJ, 1974).
[42] Conway, J. H. An enumeration of knots and links, and some of their algebraic properties. In Computational Problems in Abstract Algebra, 329–358 (Pergamon Press, 1970).
[43] Schubert, H. Knoten und vollringe. Acta Mathematica 90, 131–286 (1953).
[44] Lee, T.-C., Kashyap, R. L. & Chu, C.-N. Building skeleton models via 3-d medial surface/axis thinning algorithms. CVGIP: Graphical Models and Image Processing 56, 462–478 (1994).
[45] Reinders, F., Jacobson, M. E. D. & Post, F. H. Skeleton graph generation for feature shape description. In de Leeuw, W. C. & van Liere, R. (eds.) Data Visualization 2000, 73–82 (Springer, Vienna, 2000).
[46] Negami, S. Polynomial invariants of graphs. Transactions of the American Mathematical Society 299, 601–622 (1987).
[47] Carlyle, J. W. & Paz, A. Realizations by stochastic finite automata. Journal of Computer and System Sciences 5, 26–40 (1971).
[48] Balle, B. & Mohri, M. Spectral learning of general weighted automata via constrained matrix completion. In Advances in Neural Information Processing Systems 25, 2168–2176 (2012).
[49] Chbili, N. Ribbon graphs and temperley–lieb algebra. In Knot Theory and Its Applications, vol. 670 of Contemporary Mathematics, 299–312 (American Mathematical Society, 2016).
[50] Sunko, V. et al. Direct observation of a uniaxial stress-driven lifshitz transition in sr2ruo4. npj Quantum Materials 4, 46 (2019).
[51] Xiang, Z. J. et al. Pressure-induced electronic transition in black phosphorus. Physical Review Letters 115, 186403 (2015).
[52] Dziawa, P. et al. Topological crystalline insulator states in pb1-xsnxse. Nature Materials 11, 1023–1027 (2012).
[53] Scharlemann, M. Heegaard splittings of compact 3-manifolds. In Daverman, R. J. & Sher, R. B. (eds.) Handbook of Geometric Topology, 921–953 (North-Holland, Amsterdam, 2002).
[54] Brandes, U., Eiglsperger, M., Herman, I., Himsolt, M. & Marshall, M. S. GraphML progress report: Structural layer proposal. In Graph Drawing, vol. 2265 of Lecture Notes in Computer Science, 501–512 (Springer, 2002).
[55] Bourne, P. E. et al. Macromolecular crystallographic information file. In Methods in Enzymology, vol. 277, 571–590 (Academic Press, 1997).
[56] Abraham, M. J. et al. GROMACS: High performance molecular simulations through multi-level parallelism from laptops to supercomputers. SoftwareX 1–2, 19–25 (2015).
[57] Thompson, A. P. et al. LAMMPS—a flexible simulation tool for particle-based materials modeling at the atomic, meso, and continuum scales. Computer Physics Communications 271, 108171 (2022).
[58] Sullivan, C. B. & Kaszynski, A. A. Pyvista: 3d plotting and mesh analysis through a streamlined interface for the visualization toolkit (vtk). Journal of Open Source Software 4, 1450 (2019).
[59] Bode, B. & Dennis, M. R. Constructing a polynomial whose nodal set is any prescribed knot or link. Journal of Knot Theory and Its Ramifications 28, 1850082 (2019). 1612.06328.
[60] Ramer, U. An iterative procedure for the polygonal approximation of plane curves. Computer Graphics and Image Processing 1, 244–256 (1972).
[61] Douglas, D. H. & Peucker, T. K. Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. Cartographica 10, 112–122 (1973).
[62] Lewiner, T., Lopes, H., Vieira, A. W. & Tavares, G. Efficient implementation of marching cubes' cases with topological guarantees. Journal of Graphics Tools 8, 1–15 (2003).
[63] van der Walt, S. et al. scikit-image: image processing in python. PeerJ 2, e453 (2014).
[64] Hagberg, A. A., Schult, D. A. & Swart, P. J. Exploring network structure, dynamics, and function using networkx. In Proceedings of the 7th Python in Science Conference, 11–15 (2008).
[65] Cordella, L. P., Foggia, P., Sansone, C. & Vento, M. A (sub)graph isomorphism algorithm for matching large graphs. IEEE Transactions on Pattern Analysis and Machine Intelligence 26, 1367–1372 (2004).
[66] Keinert, B., Innmann, M., Sänger, M. & Stamminger, M. Spherical fibonacci mapping. ACM Transactions on Graphics 34, 193:1–193:7 (2015).
[67] Leutenegger, S. T., Lopez, M. A. & Edgington, J. Str: A simple and efficient algorithm for r-tree packing. In Proceedings 13th international conference on data engineering, 497–506 (IEEE, 1997).
[68] Gillies, S. et al. Shapely. Software (n.d.). All-version archive; no specific release is identified.
[69] Burton, B. A. The HOMFLY-PT polynomial is fixed-parameter tractable. In 34th International Symposium on Computational Geometry (SoCG 2018), vol. 99 of Leibniz International Proceedings in Informatics (LIPics), 18:1–18:14 (Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2018). 1712.05776.
[70] Virtanen, P., Gommers, R., Oliphant, T. E. et al. Scipy 1.0: fundamental algorithms for scientific computing in python. Nature Methods 17, 261–272 (2020).
[71] Ohser, J., Nagel, W. & Schladitz, K. The euler number of discretized sets—on the choice of adjacency in homogeneous lattices. In Morphology of Condensed Matter, vol. 600 of Lecture Notes in Physics, 275–298 (Springer, 2002).
[72] Li, L., Lee, C. H. & Gong, J. Realistic floquet semimetal with exotic topological linkages between arbitrarily many nodal loops. Physical review letters 121, 036401 (2018).
[73] Li, L., Lee, C. H. & Gong, J. Emergence and full 3d-imaging of nodal boundary seifert surfaces in 4d topological matter. Communications physics 2, 135 (2019).
[74] Lifshitz, I. M. Anomalies of electron characteristics of a metal in the high pressure region. Soviet Physics JETP 11, 1130–1135 (1960).
[75] Varlamov, A. A., Galperin, Y. M., Sharapov, S. G. & Yerin, Y. Concise guide for electronic topological transitions. Low Temperature Physics 47, 672–683 (2021).
[76] Galeski, S. et al. Signatures of a magnetic-field-induced lifshitz transition in the ultra-quantum limit of the topological semimetal zrte5. Nature Communications 13, 7418 (2022).
[77] Ichinokura, S. et al. Van hove singularity and lifshitz transition in thickness-controlled li-intercalated graphene. Physical Review B 105, 235307 (2022).
[78] Slizovskiy, S., Chubukov, A. V. & Betouras, J. J. Magnetic fluctuations and specific heat in naxcoo2 near a lifshitz transition. Physical Review Letters 114, 066403 (2015).
[79] Shi, X. et al. Enhanced superconductivity accompanying a lifshitz transition in electron-doped fese monolayer. Nature Communications 8, 14988 (2017).
[80] Buck, G. & Orloff, J. A simple energy function for knots. Topology and its Applications 61, 205–214 (1995).
[81] Schumacher, H. Repulsor: A package for handling tangent-point energy and other nonlocal energies. https://github.com/HenrikSchumacher/Repulsor. Software, source revision adc56b61f65f5958b59cbd7e1539f44ed0c5e993.
[82] Comoglio, F. & Rinaldi, M. A topological framework for the computation of the HOMFLY polynomial and its application to proteins. PLoS ONE 6, e18693 (2011).
[83] Li, M., Lei, F., Li, F. & Vesnin, A. Density of roots of the yamada polynomial of spatial graphs. Proceedings of the Steklov Institute of Mathematics 305, 135–148 (2019). 1810.12749.
[84] Huh, Y. Yamada polynomial and associated link of -curves. Discrete Mathematics 347, 113684 (2024).
[85] Vesnin, A. Y. & Oshmarina, O. A. Polynomials of complete spatial graphs and jones polynomials of the related links. Sbornik: Mathematics 216, 608–637 (2025).
[86] Harris, C. R., Millman, K. J., van der Walt, S. J. et al. Array programming with numpy. Nature 585, 357–362 (2020).
[87] Meurer, A., Smith, C. P., Paprocki, M. et al. Sympy: symbolic computing in python. PeerJ Computer Science 3, e103 (2017).
KnottedGraph: Scalable knotted-graph topology for scientific and mathematical discovery Supplementary Information
Hakan Akgün, Xianquan Yan, Kehan Liu, Zhaoyun Chen, Ching Hua Lee
Department of Physics, National University of Singapore, Singapore 117551, Singapore
Department of Computer Science, National University of Singapore, Singapore 117417, Singapore
Correspondence: Hakan Akgün, hakan.akgun@u.nus.edu; Ching Hua Lee, phylch@nus.edu.sg
25 September 2026
(a) Trefoil Polymer (LAMMPS)

(b) Petersen Spatial Network (JSON)

(c) Genus-2 Generating Spine (PLY)

(d) Moebius Ladder M8 (GraphML)

(e) Figure-Eight Knot (XYZ)

(f) Engineering Network (CSV)
(g) Cinquefoil Knot (XYZ)

(h) Warped Cubical Cage (GraphML)

(i) Lissajous Loop (JSON)

(j) Triple-Lens Necklace (CSV)


(k) Spatial Graph (JSON)
(1) Twisted Triangular Prism (CSV)

(m) Three-Component Torus Link T(3,3) (JSON)

(n) Spatial Network (GraphML)


(o) Lattice Truss (CSV)

Supplementary Fig. 1 | Different input formats are converted to knotted graphs for Yamada evaluation. Molecular structures, polymers, mathematical embeddings, engineered networks, knots, links and three-dimensional frameworks are normalized to the same knotted-graph representation and passed to the same Yamada-polynomial calculation. Representative inputs are (a) a trefoil polymer [5]; (b) a Petersen spatial network; (c) a genus-two generating spine, illustrating the handlebody–spine viewpoint [27, 28]; (d) Möbius ladder ; (e) a figure-eight knot; (f) an engineering network [7]; (g) a cinquefoil knot; (h) a warped cubical cage; (i) a Lissajous loop; (j) a triple-lens necklace; (k) a spatial graph; (l) a twisted triangular prism; (m) a three-component torus link; (n) a spatial network originally stored in GraphML [54] and converted externally to the knotted graph; and (o) a 3D truss network [7]. The polynomial displayed beneath each example is the output for that selected representation. Its invariant interpretation follows the graph and diagram conventions in Supplementary Note 3. Red spheres denote graph vertices and dark-teal curves denote the stored three-dimensional edges.
Supplementary Note 1 | From heterogeneous inputs to knotted graphs
Supplementary Note 1.A | Heterogeneous inputs and the knotted-graph interface
Each type of input enters the pipeline at the stage that matches the information it already contains. The supported routes, normalization rules and retained information are summarized in Supplementary Table 1, with the corresponding scientific input classes illustrated in Fig. 1. Scientific structures of interest can be supplied as surface or volumetric geometries even when an explicit one-dimensional graph is unavailable, for example in tubular vascular geometries [3] and level-set regions such as finite-energy Fermi volumes [14]. Related spatial-network descriptions also arise in neuronal morphologies [4], engineered systems [7, 8], and polymeric graph structures [5]. After normalization, these routes converge on a common knotted-graph representation retaining the available graph connectivity and three-dimensional edge geometry, together with connected components and optional orientation independently of any invariant. The resulting graph can then be projected and passed to exact Yamada evaluation (Fig. 2b,c); representative inputs and their corresponding values are shown in Supplementary Fig. 1.
| Input | Interface | How the input is checked and converted; what is kept |
| Molecular backbones | PDB/PDBx-mmCIF [1, 55] | The reader selects one model, one chain and one backbone atom type (for example Ca) and returns the selected atoms as an ordered backbone trace. If the file contains several chains, the user must specify which chain to use. For atoms with alternate locations, only the primary location is kept. The selected model, chain and atom type are stored with the input. mmCIF support is limited to RCSB-style _atom_site records in which each atom is written as one complete line. |
| Explicit graphs and networks | Paired node–edge CSV; direct mathematical spatial graphs | Every node must have finite three-dimensional coordinates. Node and edge attributes are kept. If an edge is supplied with its own polyline, the polyline endpoints are checked against the positions of the two nodes it connects. This route covers vascular and neuronal networks [3, 4], engineering networks [7, 8] and mathematical spatial graphs [19, 20] (Fig. 1b,d,h). GraphML, SWC and graph-JSON files in other layouts are converted to this node–edge form before being read. |
| Polymer snapshots | GROMACS [56]; LAMMPS [57] | Atoms from one snapshot are arranged into a chain. For GROMACS files, atoms are ordered by atom ID and coordinates are converted with an explicit unit scale (by default nm→Å). For LAMMPS files, only the first frame is read, using the unscaled x/y/z columns. Atoms are ordered by a user-chosen column (by default atom ID), and if a mol column is present they are filtered by molecule. Neither reader infers chemical bonds or unwraps periodic boundaries, so the selected atoms must already form the intended chain in the intended order. |
| Coordinate curves | Finite (N, 3) arrays, including JSON or NPY | An open curve is stored as a single polyline. A closed curve is stored as a self-loop, an edge that starts and ends at the same vertex and carries the ordered coordinates. The user must request closure explicitly; it is never inferred from how close the two ends are. Closure can be requested in two ways. Direct closure adds a final segment from the last point back to the first. Metadata-only closure marks the curve as closed without adding any segment. |
| Surfaces, volumes and fields | Surface meshes; volumetric regions; sampled fields and Hamiltonians | Surface meshes are loaded as PyVista PolyData [58]. Cleaning and triangulation are applied only when requested. Meshes that are empty, contain non-finite values or have open boundaries are reported, and open boundaries are not filled automatically. The adapter returns the mesh together with a list of detected issues. Whether a given mesh can be reduced to the intended graph spine has to be judged for each application. Hamiltonian-derived level sets or occupied regions (Fig. 1e) [14], volumetric regular neighborhoods (Fig. 1f) [27, 28] and vector-field curves (Fig. 1g) [15] are each converted to a knotted graph by their own geometry-to-graph route. The volumetric route is described in Supplementary Note 1.C. |
| Analytic constructions | Named knots, links, torus types and Artin braid words | These inputs are generated directly from their mathematical definitions, so no file is read. When a braid word has to be realized as the zero set of a polynomial field, the field is built with the semiholomorphic construction of Bode and Dennis [59]. |
| Projected representations | Accepted diagrams or PD codes | No three-dimensional geometry is required. An existing diagram or PD code is passed directly to exact Yamada evaluation (Supplementary Note 3), skipping graph construction and projection. |
Supplementary Table 1 | Input routes and normalization. Each row lists one class of input, the formats or objects accepted (Interface), and how the input is checked and converted, together with the information kept (last column). Each input enters at the stage that matches the information it already contains. Curves and explicit graphs enter directly as knotted graphs. Surfaces, volumes and fields first pass through graph construction. Diagrams and PD codes enter directly at invariant evaluation.
Supplementary Note 1.B | Regular neighborhoods and spatial-graph spines
For the surface and volumetric inputs summarized in Supplementary Note 1.A, when a volumetric region is a regular neighborhood of a spatial network, a one-dimensional spine retains its handle structure, cycle organization and spatial entanglement while discarding local thickness and boundary-shape details, as shown in Fig. 1f. Here we examine the corresponding computational problem of recovering this graph spine from the volumetric geometry, shown in Fig. 2a.
To formalize what information a recovered spine must preserve, it is useful first to distinguish graph connectivity from spatial embedding:
Abstract graph. A graph specified by its vertices, edges and incidence relations, independent of any particular realization in space:
Spatial graph. An embedding of an abstract graph in three-dimensional space, , for which the embedding itself is part of the mathematical object [19, 20].
The same abstract graph can admit topologically distinct spatial realizations when their spatial embeddings differ through knotting, linking or other three-dimensional arrangements. More generally, spatial complexity can increase independently of the local connectivity of the underlying abstract graph. The structured families in Fig. 3a–f, for example, represent three distinct abstract graph families. Within each family, the graph connectivity is preserved, while the spatial embedding becomes progressively more crossing-rich. Their regular planar projections therefore acquire increasing numbers of crossings even though the underlying family-specific connectivity rule remains unchanged. The equivalence is therefore an equivalence of embeddings rather than of graph connectivity alone. Two spatial graphs are ambient-isotopic when a continuous deformation of the surrounding three-dimensional space carries one to the other without cutting edges or passing nonincident edges through one another [19, 20]. Spatial-graph invariants such as the Yamada invariant, introduced in Supplementary Note 3, probe this embedding-dependent topological structure. KnottedGraph operates directly on the corresponding spatial graphs and, when required, converts their spatial embedding into the diagram needed for exact invariant evaluation.
For the surface and volumetric routes summarized in Supplementary Note 1.A, the spatial graph must be recovered from the surrounding geometry. The connection between volumetric regular neighborhoods and spatial graphs can be formalized through the following notions [27, 28]:
Regular neighbourhood. For a spatial graph G, a regular neighbourhood is a sufficiently small three-dimensional thickening of G, in which vertices expand into compact junction regions and edges into connecting tubes.
Handlebody. For connected G, its regular neighbourhood is a handlebody: a compact, connected, orientable three-manifold obtained from a three-ball by attaching 1-handles.
Handlebody-link. For disconnected G, the regular neighbourhoods of its connected components form a disjoint collection of embedded handlebodies, referred to as a handlebody-link.
Spine. A spatial graph is a spine of a handlebody when deformation retracts onto .
The deformation retract provides the mathematical idealization of reducing a volumetric regular neighborhood to a spatial graph. In the regular-neighborhood setting, the resulting spine represents the thickened object. Numerically, we use the term candidate spine until the correspondence with the input region has been established.
A handlebody generally admits many graph spines. Subdivision, local expansion or contraction and different geometric representatives can change the graph while preserving the represented handlebody-link. This equivalence is characterized by the following result:
Theorem 2.3 [28, Theorem 2.3]. Two spatial graphs without isolated vertices represent equivalent handlebody-links if and only if they are related by a finite sequence of admissible spatial contraction moves and ambient isotopies.
This theorem establishes the equivalence but does not prescribe how to recover a representative from sampled three-dimensional geometry. Because one handlebody can admit many equivalent spines, the computational target is not a unique geometric centerline but an admissible representative of the same handlebody-link. The contraction moves in this statement retain the spatial embedding. Graph contractions alone do not establish the same equivalence, and the Yamada polynomial of a selected spine need not be invariant under every change of spine.
KnottedGraph implements numerical knotted-graph construction through voxelization, thinning, multiscale skeleton-to-graph construction and scale-controlled cleanup (Fig. 2a; Supplementary Fig. 2). The recovered spine can then be analyzed through its graph connectivity and cycle structure or projected (Fig. 2b) for topological invariant evaluation (Fig. 2c). The benchmark in Supplementary Note 4.B tests this construction against volumetric regular neighborhoods generated from known ground-truth spatial graphs.
The same representation principle also points beyond the ordinary handlebody setting. Volumetric geometries with distinguished inner boundaries, enclosed voids or nested boundary components motivate a prospective compression-body formulation. A compression body generalizes a handlebody by allowing a distinguished positive boundary together with additional negative boundary components [53]. Representing such inputs therefore requires boundary-resolved graph data that record which graph belongs to which boundary component and how those components are nested.
Surface

(b)
(d)
Raw graph
Filled mask

(e)
(c)
Leaf removal
Skeleton

(f)
Chain collapse

(g)
Edge contraction

(h)
Smoothing

(i)
Planar diagram



Supplementary Fig. 2 | A volumetric regular neighborhood is thinned, converted to a graph and cleaned before projection. (a) Input boundary surface. (b) Filled volumetric mask used for three-dimensional thinning. (c) One-voxel-wide skeleton obtained with Lee thinning. (d) Raw knotted graph constructed from the voxel skeleton by identifying junction regions across neighbouring local scales, selecting graph connectivity recurring across the tested scales and tracing the intervening degree-two chains as three-dimensional edge polylines. (e) Removal of terminal leaf artifacts when these are not part of the intended graph. (f) Collapse of redundant degree-two chains into single graph edges, retaining their three-dimensional edge geometry. (g) User-controlled contraction of sufficiently short local edges, used to merge voxel-scale fragmentation of physical junctions. (h) Geometric simplification of the retained edge polylines to suppress voxel-scale jaggedness without changing graph connectivity. (i) Regular projection of the cleaned knotted graph for crossing detection and subsequent PD-code construction. Panels (e–h) isolate the effects of the cleanup primitives; in the thick-handlebody benchmark the call order is short-edge contraction, leaf removal, degree-two simplification and Ramer–Douglas–Peucker smoothing [60, 61]. Chain collapse changes only graph subdivision, whereas leaf removal and short-edge contraction are scale-dependent operations whose effect is validated against ground truth.
The boundary-resolved construction developed in the companion work [14] motivates extending these general-purpose computational interfaces. The computational problem is also more difficult than the handlebody construction treated here. In the handlebody case, the volumetric region can be represented by a one-dimensional graph spine, allowing the pipeline to proceed through volumetric thinning, junction identification and knotted-graph cleanup. For geometries with multiple distinguished boundary components, a single graph need not contain the full topological information: the deformation retract can involve boundary surfaces together with graph-like attachments. A computational representation must therefore preserve graph connectivity, spatial embedding, boundary attachment, nesting and the relative topology of the boundary components. Skeleton-to-graph reduction can erase this information, so new boundary-aware graph construction, certification and invariant-evaluation procedures are required.
Supplementary Note 1.C | Skeleton extraction and multiscale graph construction
The handlebody–spine correspondence [28] supplies the topological target for graph construction in Fig. 2a. Given a finite-resolution surface or volume, the task is to recover a knotted graph whose graph connectivity and three-dimensional edge geometry represent that object and remain suitable for subsequent topological analysis. The reduction is shown panel by panel in Supplementary Fig. 2.
Surface to filled volume: panels (a,b). The pipeline begins from a surface or volumetric input (Supplementary Fig. 2a). When the input is supplied as a surface, the enclosed region is converted to the occupied three-dimensional mask shown in Supplementary Fig. 2b; field- or volume-derived inputs can enter directly at this stage. Surface handling uses PyVista [58], and level-set surface extraction uses Lewiner marching cubes through scikit-image [62, 63]. The volume mask is the object on which the subsequent digital thinning operation acts. Its correspondence with the analytic source is a separate question.
Filled volume to one-dimensional skeleton: panel (c). Before thinning, empty margins are cropped so that computation is restricted to the occupied bounding box. Then it is thinned with the three-dimensional Lee algorithm through scikit-image [44, 63], producing the one-voxel-wide backbone in Supplementary Fig. 2c. The cropped result is restored to the original voxel coordinate frame before graph construction. The implementation therefore separates the morphological reduction itself from the later task of deciding which parts of the digital skeleton constitute graph vertices and graph edges.
Voxel skeleton to raw knotted graph: panel (d). The one-voxel-wide skeleton in Supplementary Fig. 2c is still a digital object: its occupied voxels specify a centerline, but graph vertices and graph edges have not yet been identified. The next stage converts this voxel skeleton into the explicit knotted graph shown in Supplementary Fig. 2d.
Following voxel-skeleton graph constructions [45], skeleton voxels that touch through a face, edge or corner are first connected using the standard 26-neighbour adjacency of a three-dimensional voxel grid (6 face-, 12 edge- and 8 corner-sharing neighbours). KnottedGraph then suppresses a direct diagonal lattice connection whenever the same local connection is already represented through an occupied intermediate voxel by two strictly shorter lattice steps. This additional cleanup prevents the discrete neighbourhood rule from inserting redundant shortcuts that can create artificial local cycles or junction structure.
For larger skeletons, the same construction is carried out by a compiled C++ implementation. It builds the shortcut-reduced 26-neighbour voxel graph once and traces the candidate junction sizes directly on this sparse representation. For each candidate size, it first records only the information needed to choose between candidates—the graph connections, edge lengths, edge point counts and whether the stored geometry is valid. After the cross-scale recurrence and multigraph isomorphism tests select one scale, three-dimensional edge polylines are constructed only for that selected graph.
The cleaned voxel network is converted to a graph using the standard degree-based skeleton interpretation [45]. Degree-two voxels form the interiors of one-dimensional edges, whereas connected regions containing voxels of degree different from two identify endpoints or junctions. Each such region is represented by a graph vertex, and the intervening degree-two chains are traced explicitly as graph edges. The ordered three-dimensional coordinates along each chain are retained, so this step preserves both graph connectivity and the three-dimensional edge geometry. Components consisting entirely of degree-two voxels are retained separately as closed loops. Isolated vertices and small tree components are also included when accounting for the whole input; their removal would change its component count.
The main difficulty is that voxelization does not provide a unique local representation of a physical junction. A single thick junction can thin to a cluster of nearby branch voxels and can therefore be misinterpreted as several graph vertices connected by very short edges. Simply merging all nearby vertices is not sufficient, because distinct junctions may also lie close in space. To avoid choosing one arbitrary junction-clustering scale, KnottedGraph follows the multiscale construction summarized in Eq. (2): it constructs candidate graphs from the same sparse voxel skeleton across neighbouring local junction-zone scales and uses recurrence of the resulting graph connectivity across scales to resolve this ambiguity.
Starting from the zero-radius trace, candidate graphs are generated through progressively expanded junction regions, up to a user-specified number of voxel hops. Each candidate must contain nondegenerate three-dimensional edge geometry and must avoid anomalously short junction connections relative to the local edge scale. If an expected maximum valence is known, it is incorporated as an additional admissibility constraint; when no such prior is supplied, no valence bound is inferred. Thus multi-scale topology selection does not require advance knowledge of the graph degree.
Candidate graph topologies are compared across neighbouring scales using full multigraph isomorphism through NetworkX [64, 65]. Two consecutive clean, isomorphic graph candidates provide the strongest cross-scale consistency signal, in which case the smaller-scale representative is retained. The finer candidate that will actually be returned must pass the short-edge check. The next coarser candidate only needs to be a clean isomorphic graph, because it is being used only to confirm that the same topology persists at the next scale. Requiring that coarser graph to pass the same short-edge test can incorrectly reject a stable finer graph just when two nearby junction regions are beginning to merge at the coarser scale. If no consecutive pair is found, the most recurrent valid isomorphism class across the tested scales is selected, provided that it occurs at least twice, again preferring its smallest-scale representative. A topology observed at only one expanded scale is not treated as evidence of cross-scale stability; if no valid topology recurs, the direct zero-radius trace is retained; an unsupported scale-dependent candidate is not promoted.
These comparisons test recurrence of the abstract graph over the chosen scales; they do not establish equivalence of its spatial embedding. The procedure combines local geometric validity with cross-scale graph-topology consistency and allows physical information about vertex valence to strengthen the selection when such information is available. For example, in the thick-handlebody construction benchmark (Supplementary Note 4.B), the ground-truth graphs are subcubic, so the optional maximum-degree prior is set to three and junction expansion is tested through four voxel hops. At this stage the output is a knotted graph with explicit junctions and three-dimensional edge geometry. Residual artifacts can remain at the geometric scale of the voxelization.
Leaf removal: panel (e). Terminal degree-one edges require different treatment depending on the object being represented. For a general knotted graph, a leaf can be part of the intended graph and must not be removed. In the handlebody–spine setting, however, a pendant tree edge does not introduce an additional cycle or handle in the regular neighbourhood. An admissible spatial contraction of such an edge changes the chosen graph spine without changing the represented handlebody-link, consistent with the contraction-move equivalence of Theorem 2.3 [28]. Accordingly, when the computational target is the handlebody topology and not a prescribed abstract graph, terminal tree protrusions may be removed to obtain a simpler equivalent spine, as illustrated in Supplementary Fig. 2e. This operation is not applied universally: for biological trees, open polymers or other applications in which degree-one edges are themselves part of the scientific object, they are retained.
Degree-two chain collapse: panel (f). After terminal artifacts have been dealt with, long sequences of degree-two vertices can remain solely because a continuous graph edge was sampled by many voxel or graph points. Panel Supplementary Fig. 2f removes this redundant subdivision. Consecutive degree-two graph segments are concatenated into a single edge between the surrounding significant vertices, and the ordered three-dimensional polyline along the entire original chain is retained. Thus this operation changes the combinatorial subdivision of the graph but not the represented graph edge. Closed degree-two components remain represented as self-loops and are not discarded.
Short-edge contraction: panel (g). A junction recovered from the voxel skeleton can be split across several nearby graph vertices by finite-resolution thinning and skeleton-to-graph conversion. Panel Supplementary Fig. 2g simplifies such local structure by contracting sufficiently short edges between distinct vertices. In the handlebody–spine setting, this operation has a direct topological justification: an admissible edge contraction changes the chosen spatial-graph spine but not the handlebody-link represented by its regular neighbourhood, consistent with the contraction-move equivalence of Theorem 2.3 [28]. The retained vertex is repositioned between the original endpoints and the incident edge polylines are relinked to the contracted junction.
The geometric threshold selects which short connections are proposed for contraction. It does not by itself establish that the endpoint motion or the relinked polylines realize an admissible spatial move. Those geometric checks are needed in addition to the abstract contraction. The threshold must also be chosen conservatively because two nearby junctions can represent scientifically distinct graph connectivity even when their contraction is permissible at the level of handlebody–spine equivalence. Accordingly, short-edge contraction is an explicit, user-controlled operation and is not applied as a generic simplification.
Geometric smoothing: panel (h). Once graph connectivity has been fixed, the edge geometry is regularized without changing connectivity. Panel Supplementary Fig. 2h shows this geometric simplification. The voxel-scale staircase structure of each stored polyline is reduced using the Ramer–Douglas–Peucker algorithm [60, 61], implemented through fastrrdp. The retained polyline endpoints are then normalized to the corresponding graph-vertex coordinates and consecutive duplicate samples are removed. This operation improves the numerical conditioning of later projection and crossing detection and leaves graph connectivity unchanged.
Knotted graph to projected diagram: panel (i). The output of the graph-construction stage is therefore an explicit knotted graph, not only a binary skeleton. Its vertices carry three-dimensional positions and its edges retain ordered spatial polylines. This object can already be used for graph connectivity, cycle and geometric measurements. When a Yamada invariant is required, the cleaned graph is passed to the generic-projection stage shown in Supplementary Fig. 2i. A suitable viewing direction is selected, edge over/undercrossing information is assigned at the projected crossings and the resulting diagram is converted to the PD code used by the exact Yamada calculation. The details of this final projection step are given in Supplementary Note 2.
The panel sequence separates three operations: volumetric topology reduction (a–c), digital skeleton-to-graph construction (c,d), and explicit graph/geometric cleanup (e–h) before the representation changes from three dimensions to a projected diagram in (i). The recovery benchmark in Supplementary Note 4.B tests whether this entire sequence returns the intended connectivity and normalized Yamada invariant for volumetric regular neighborhoods generated from known spatial ground-truth graphs.
Supplementary Note 2 | From knotted graphs to projected diagrams
Once graph construction has produced a knotted graph with the intended connectivity and spatial geometry, the problem changes from recovering the object to projecting its spatial embedding to a diagram for exact Yamada evaluation (Fig. 2b). Projection produces the diagram required by the topological invariant calculation.
The input is first normalized to the package’s knotted-graph MultiGraph contract: every graph vertex has a finite three-dimensional position and every graph edge is represented by an ordered three-dimensional polyline whose endpoints coincide with its incident vertices. Projection then changes only the representation of this fixed embedding; it does not alter graph connectivity. This layer combines deterministic spherical-Fibonacci view sampling [66], spatially indexed segment-intersection queries [67, 68], and planar-diagram encoding [29] under standard spatial-graph conventions [19, 20].
The methodological advance in KnottedGraph is to integrate these components into a projection procedure with explicit acceptance checks and a retained record tailored to knotted graphs: genuine graph vertices are kept distinct from projection crossings, nongeneric views are rejected and are never forced into a diagram, edge over/undercrossing information is determined from the original three-dimensional edge geometry, duplicate crossing incidences are resolved consistently along the stored edge paths, and the accepted projection is retained together with its crossing structure and PD encoding for the exact polynomial evaluated downstream. When the program finds a projected intersection, it also records which two original graph edges produced it and the distance of the intersection along each edge. These are exactly the positions at which the edges must later be cut to build the PD diagram, so the program does not need a second geometric search to locate the same crossings again.
| Projection event | Treatment |
|---|---|
| Overlapping or collinear projected segments | Reject the candidate as nongeneric; do not assign an artificial crossing. |
| Near-tangent four-incidence intersection | Reject when cyclically adjacent projected half-edge directions approach tangency within the angular tolerance, because the local crossing order is not numerically well resolved. |
| Unresolved edge height | Reject a projected crossing when the competing three-dimensional edge segments have indistinguishable heights within the geometric tolerance, so that an edge over/undercrossing assignment cannot be made reliably. |
| Valid regular projection | Retain the projection record and continue to ordered crossing detection and PD construction. |
Supplementary Table 2 | Criteria for accepting a regular spatial-graph projection. Candidate views are rejected whenever the projected geometry does not support an unambiguous diagram; invalid views are excluded rather than coerced into a PD code.
Supplementary Note 2.A | Sampling and selecting regular projections
A user may prescribe one Euler rotation explicitly, in which case that view is used directly. Otherwise KnottedGraph evaluates a deterministic family of candidate viewing directions, producing the candidate diagrams and crossing counts defined in Eq. (3). The default multi-view route uses an upper-hemisphere spherical-Fibonacci/golden-angle construction [66], as illustrated in Supplementary Fig. 4a with the projections and for the same knotted graph. Opposite viewing directions are not sampled separately and the in-plane roll is fixed, because these choices do not generate distinct diagram topology. For each candidate direction, the knotted graph is rigidly rotated and projected to the xy plane. The subsequent crossing detection, edge over/undercrossing determination and PD serialization are described in Supplementary Notes 2.B and 2.C and illustrated in Supplementary Fig. 3.
The target is a regular, numerically resolvable diagram suitable for exact evaluation, not simply a visually convenient projection. Each candidate view is therefore subjected to explicit acceptance guards rather than being forced into a PD code. When several candidate views are requested, the program first counts the crossings in each view without building its complete vertices, arcs and PD code. The views are ordered from fewest to most crossings, with generation order breaking ties, and the complete diagram is then built only for the best candidates until a valid one is obtained. The same minimum-crossing rule is therefore retained, avoiding full PD construction for views that will not be selected.
For normalized Yamada evaluation, the program performs one additional check on difficult diagrams. If the minimum-crossing view has at least 12 crossings and its processing order would require at least 12 arc ends to remain unresolved at the same time, the other sampled views are examined as well. An alternative view is accepted only if it lowers this maximum by at least two arc ends. This matters because the exact calculation can sometimes be easier for a diagram with slightly more crossings if those crossings can be processed with fewer unresolved arc ends at once. If no candidate passes the acceptance criteria in Supplementary Table 2, projection terminates with an error and does not manufacture a diagram.
Supplementary Note 2.B | Crossing detection and edge over/undercrossing determination
Once a candidate view has passed the genericity checks in Supplementary Note 2.A, its planar geometry is fixed, but the projection is not yet a combinatorial diagram. The apparent intersections must first be identified, associated with their parent graph edges and assigned edge over/undercrossing information using the original three-dimensional geometry. This is the role of the crossing-recovery stage.
Crossing detection acts on the stored edge polylines; the graph edges are not replaced by straight chords between graph vertices. Every polyline is split into two-point segments. Along with each segment, the program stores which original graph edge it belongs to and the distance from the start of that edge to the start of the segment. An STR tree generates candidate segment pairs before vectorized Shapely intersection tests [67, 68]. When an intersection is found, its distance along both original edges is therefore obtained immediately from the same calculation. The program can later split those edges at the crossing without building another spatial index or searching for the crossing a second time.
Line overlaps are treated as nongeneric projection degeneracies. Point intersections are checked against the corresponding original three-dimensional segments: the coordinate of each segment is linearly interpolated at the projected intersection. If the two interpolated heights agree within tolerance at a projected intersection of nonincident edges, the view is rejected because it does not define a resolvable edge over/undercrossing. Shared graph endpoints are treated as incidences rather than ordinary crossings. Otherwise, the relative heights determine which edge segment passes over the other.
The same geometric crossing can be encountered more than once when it lies at an internal polyline sample shared by adjacent segments. Such duplicate incidences are merged before diagram construction. Endpoint directions are computed from distinct polyline samples, skipping degenerate successive segments. The retained crossings are already ordered by their recorded arclength along each original projected edge. The output of this stage is an ordered crossing structure attached to the accepted projection: for every graph edge, the software knows which crossings occur along it, in what order, and which edge segment is over or under at each event. These ordered crossing positions provide the cut locations used to construct the diagram arcs in Supplementary Fig. 3a and, across multiple accepted views, lead to the distinct projection-specific diagram representations shown in Supplementary Fig. 4b.
Supplementary Note 2.C | Arc splitting, cyclic incidence and PD serialization
The ordered crossing structure obtained in Supplementary Note 2.B is converted into the discrete incidence data used by the exact Yamada calculation. The conversion for one accepted projection is illustrated in Supplementary Fig. 3; the same
Arc encoding
(b)
PD code written on the diagram


V[3,0,2]; V[4,6,3]; X[4,2,5,1]; X[1,5,0,6]
Supplementary Fig. 3 | PD code records graph vertices, crossings, cyclic order and edge over/undercrossing information. (a) Every projected graph edge is cut at its ordered crossing positions, producing arcs whose endpoints are either graph vertices or projection crossings; each resulting arc receives a discrete label. (b) Graph vertices are serialized as records containing incident arc labels in counter-clockwise order; projection crossings are serialized as records. The four crossing incidences are ordered counter-clockwise and cyclically shifted, when necessary, so the overpassing arc pair occupies the convention used by the Yamada calculation. Numerical arc labels are arbitrary identifiers: incidence, cyclic order and edge over/undercrossing information is retained by the PD code.
serialization applied independently to several accepted views of one spatial embedding is shown in Supplementary Fig. 4c. Panel Supplementary Fig. 3a shows the projected spatial graph after its graph edges have been cut at the ordered crossing positions. The resulting arc pieces are assigned the discrete labels 0, 1, ..., 6 shown directly on the diagram. For example, the upper graph vertex is incident to arcs 3, 0 and 2; the lower graph vertex is incident to arcs 4, 6 and 3. The longer outer edge segments are likewise subdivided where they encounter the two projection crossings, so the labels identify the individual arc segments between successive graph vertices or crossing objects.
These labeled arcs are then converted into incidence records in Supplementary Fig. 3b. Genuine graph vertices are serialized as
with the incident arc labels ordered counter-clockwise around the vertex. Thus the upper and lower degree-three vertices in the example become, respectively,
exactly as indicated by the brown blocks in Supplementary Fig. 3b.
For a crossing, the four incident arcs are first ordered counter-clockwise in the projection plane, and the three-dimensional height comparison from Supplementary Note 2.B determines which opposite arc pair is overpassing. The record is then written starting from an incidence belonging to the overpassing arc pair and continuing counter-clockwise, so that the first and third entries correspond to the overpassing arc pair and the second and fourth entries to the underpassing arc pair. In the example, the two blue blocks in Supplementary Fig. 3b therefore give
For the first crossing, arcs 4 and 5 form the overpassing pair, so the record starts from arc 4; for the second, arcs 1 and 0 form the overpassing pair, so the record starts from arc 1. The particular starting arc within the overpassing pair has no independent topological significance; it fixes a consistent cyclic representative of the same crossing convention.
Then, these four local records are assembled into the complete PD code displayed at the bottom of panel (b),
This completes the representation change from a knotted graph to the PD-code input required by the exact invariant calculation. This representation is projection dependent: different generic views of the same spatial embedding can produce different crossing layouts, arc labels and PD strings, as shown in Supplementary Fig. 4c. These projection-specific PD representations are the inputs to the exact invariant calculation developed next.
Supplementary Note 3 | Exact Yamada evaluation from PD codes
The preceding section converts each accepted projection into a complete PD code. KnottedGraph then automates the remaining exact Yamada-polynomial evaluation (Fig. 2c). The Yamada polynomial [25, 26] was introduced as a polynomial invariant for spatial graphs. At the diagram level, the raw polynomial is a regular-isotopy quantity and can change under a Reidemeister-I move by a monomial factor. After normalization, this dependence is removed and the resulting polynomial is invariant under rigid-vertex isotopy. When every graph vertex has degree at most three, i.e. when the graph is subcubic,

(b)



(c)
: V[2, 1, 0]; V[7, 11, 1, 5, 9, 4]; V[6, 0, 8]
X[4, 9, 3, 10]; X[8, 11, 7, 10]; X[3, 5, 2, 6]
: V[0, 2, 1]; V[9, 4, 7, 11, 1, 5]; V[8, 6, 0]
X[4, 9, 3, 10]; X[8, 11, 7, 10]; X[3, 5, 2, 6]
: V[1, 0, 2]; V[11, 1, 5, 4, 9, 7]; V[6, 0, 8]
X[2, 6, 3, 5]; X[7, 10, 8, 11]; X[4, 9, 3, 10]
(d)
Supplementary Fig. 4 | Different regular projections give different PD codes; normalized Yamada values are projection independent for the tested subcubic graphs. (a) Three accepted viewing directions , and are selected for the same three-dimensional spatial graph using the procedure of Supplementary Note 2.A. (b) Crossing detection and edge over/undercrossing determination (Supplementary Note 2.B) produce distinct diagrams. (c) Each diagram is independently serialized according to Supplementary Note 2.C, producing its own arc labels and records. The displayed graph contains a six-valent vertex and is therefore not subcubic. (d) The corresponding normalized Yamada outputs need not agree for this higher-valence example when a common rigid-vertex structure has not been established. Higher valence alone does not explain every discrepancy. Thus successful projection and exact polynomial evaluation do not by themselves imply projection-independent invariant characterization outside the admissible subcubic regime used for the multi-view consistency tests in Supplementary Note 4.A.
the additional vertex-rotation move required for pliable-vertex isotopy does not introduce a new ambiguity. For subcubic spatial graphs, the normalized Yamada polynomial is therefore invariant under pliable-vertex isotopy and can be used as an ambient-isotopy invariant of the spatial embedding: different normalized polynomials certify topologically distinct embeddings, although equality of the polynomial does not imply equivalence [25, 26].
For a spatial graph represented by a chosen planar projection, denotes the raw regular-isotopy Yamada polynomial. The normalization convention is defined in Eq. (7). For , the minimum degree is undefined and we set directly. This evaluated zero is distinct from an unavailable calculation. When it is necessary to distinguish different projections of the same spatial graph, we indicate the chosen projection by a subscript, writing . For subcubic spatial graphs, is independent of the accepted generic projection , so the projection label can be suppressed and the invariant written simply as . For higher-valence graphs, however, normalization alone need not remove dependence on the local cyclic arrangement at a graph vertex, and the projection label must therefore be retained.
The multi-view example in Supplementary Fig. 4 shows this distinction directly. As described in the preceding section, Supplementary Fig. 4a–c constructs three independent PD codes for , and from accepted regular projections of the same three-dimensional spatial graph G. The graph contains a six-valent vertex, visible for example through the six-entry vertex record in Supplementary Fig. 4c, and is therefore not subcubic. The quantities displayed in Supplementary Fig. 4d are the normalized polynomials
yet they do not all coincide. The selected diagrams do not establish one common rigid-vertex structure, so these outputs are retained with their diagrams and are not compared as invariants of the underlying pliable graph. Higher valence alone does not diagnose every disagreement: diagram construction and the vertex convention still need to be checked. Multi-view invariant-consistency tests are consequently performed on subcubic spatial graphs, as described in Supplementary Note 4.A.
The computational contribution developed here is complementary to this topological distinction. KnottedGraph provides a general exact algorithm for computing the Yamada polynomial of an arbitrary supplied PD representation, including graphs containing higher-valence vertices; whether the normalized result can subsequently be interpreted as a projection-independent spatial-graph invariant depends on the graph class described above. The performance of our library is demonstrated in Fig. 3, where the same algorithm reproduces independently published Yamada formulas [32, 33] on structured diagrams containing up to 500 crossings.
Supplementary Note 3.A | Local crossing relation and the formal resolution space
The three local choices are shown directly in Eq. (4): the side smoothing carries weight Y, the top smoothing carries weight and the vertex resolution carries no additional power of Y. The complete mathematical state sum and the crossing-free graph

(b)
(c)

0
(d)

(e)


(f)
(g)

(h)

(i)

(j)


Supplementary Fig. 5 | The exact three-state Yamada relation is evaluated without calculating every resolution independently. (a) A two-crossing diagram whose direct expansion contains complete resolutions. (b–j) The nine combinations obtained by assigning the side-smoothing, top-smoothing or vertex resolution independently to the two crossings, with local weights , and 1, respectively, according to Eq. (4). Different resolutions already give repeated polynomial outcomes, for example (c,e), (d,h) and (g,i). During larger calculations, equivalent partial resolutions are combined as soon as their remaining connections are the same, and their exact Laurent-polynomial contributions are summed. This reduces repeated work without changing the Yamada algebra [26].
contribution are given in Eqs. (5) and (6). The algorithm preserves these relations exactly; the computational improvement comes from combining equivalent intermediate connectivity states instead of evaluating every complete resolution independently.
The resulting formal resolution count is given in Eq. (8). Here we make this construction explicit through the two-crossing example in Supplementary Fig. 5. Because each crossing can independently take the side-smoothing, top-smoothing or vertex state, the diagram in Supplementary Fig. 5a has complete resolution assignments, displayed in Supplementary Fig. 5b–j.
Even this two-crossing example already contains repeated results. The resolutions in Supplementary Fig. 5c and Supplementary Fig. 5e give the same resolved-graph polynomial; the same occurs for Supplementary Fig. 5d and Supplementary Fig. 5h, and for Supplementary Fig. 5g and Supplementary Fig. 5i. The algorithm detects this more generally during the calculation: whenever two partial resolutions have become equivalent for everything that remains to be processed, their weighted polynomial contributions are combined. Equality of a resolved-graph polynomial must be distinguished from its local crossing weight.
Supplementary Note 3.B | Compiling the PD code and removing redundancies
The state sum and crossing-free graph polynomial in Eqs. (5) and (6) are the classical Yamada/Negami ingredients [26, 33, 46]. The graph-vertex splitting, state-combination and ordering procedures below are implementation choices of KnottedGraph. The first computational improvement is to record the PD connectivity once before the exact Yamada evaluation begins. From the and records constructed in Supplementary Note 2.C, the algorithm stores each edge's endpoints and the two smoothing connections at each crossing in Eq. (4).
Before the Yamada evaluation, the same stored connectivity is also used to remove admissible Reidemeister-II redundancies [26]. In a cancellable bigon, the same edge segment passes over at both crossings. The edge segments can then be separated without changing their topology, so explicitly resolving both crossings would introduce unnecessary cases. The proposed cancellation below illustrates why incidence alone is insufficient: as drawn, its crossing assignment fails this edge condition.

Rejected cancellation. The displayed arrow is not a valid RII move: different edge segments pass over at its two crossings. A cancellable bigon has the same edge segment over at both crossings.
Reidemeister II is useful here because it preserves the raw regular-isotopy Yamada polynomial and directly reduces the number of crossings; the corresponding regular-isotopy behavior follows the Yamada diagram relations [26]. Reidemeister I changes the raw polynomial by a monomial factor, whereas Reidemeister III does not reduce the crossing number. Each admissible Reidemeister-II cancellation removes two crossings, reducing the formal resolution space from to .
The algorithm finds these configurations directly from the stored edges. It searches for two crossings joined by exactly two edges and checks that these edges occupy the required adjacent positions at both crossings and that the same edge segment is over at both. The other two edges at each crossing are then followed to determine how the edges reconnect after the crossings are removed. If this reconnection is unambiguous and has four distinct surviving endpoints, the two crossings and the two edges between them are deleted and the external edges are reconnected pairwise. The remaining edge and crossing indices and the corresponding smoothing connections are updated, and the procedure is repeated until no further pair remains.
Supplementary Note 3.C | Combining equivalent connectivity states in exact Yamada evaluation
The calculation starts from the PD representation described in Supplementary Note 2.C. At this point the three-dimensional embedding has already been converted to a combinatorial diagram: graph vertices are stored as records, crossings as records, and the arc labels specify how these local objects are connected (Supplementary Fig. 3). The remaining problem is therefore the exact evaluation of the Yamada polynomial from this fixed diagram.
The mathematical calculation to be reproduced is the state sum introduced in Eq. (5). At every crossing, the local relation Eq. (4) gives three possibilities: the side smoothing with weight Y, the top smoothing with weight and the vertex resolution with unit local weight. A complete resolution state chooses one of these three possibilities at every crossing, producing a crossing-free graph . The corresponding contribution to the raw diagram polynomial is
and summing these contributions over all complete states gives Eq. (5). Since every crossing independently admits three choices, a diagram with crossings formally contains complete resolution assignments, as stated in Eq. (8).
The two-crossing example in Supplementary Fig. 5 illustrates this direct construction. Panel (a) contains two crossings and panels (b–j) display the resulting complete assignments. The repeated outcomes visible there already show that different resolution histories can eventually contribute the same resolved-graph polynomial. The algorithm applies the same idea before the resolution tree is completed, processing the diagram one local object at a time and combining partial histories as soon as the unprocessed part can no longer distinguish them.
It is useful to view this procedure as a reordering of the sums already present in Eqs. (5) and (6). A direct implementation would first generate each complete crossing-resolution state s, construct its crossing-free graph , and then evaluate the edge-subset sum in Eq. (6) separately for that graph. The present algorithm instead accumulates the same local crossing weights, graph-vertex signs, edge-subset signs and cycle factors progressively. Partial calculations that have become identical with respect to everything still unprocessed are summed immediately.
At an intermediate stage, imagine a conceptual boundary separating the part of the diagram that has already been processed from the part that remains to be processed. An arc that has entered the processed part but continues to a crossing, vertex or connection that has not yet been processed intersects this boundary in an open arc end. These open ends are bookkeeping objects; they are not physical dangling ends of the original graph. They identify the only places through which later operations can interact with the part of the diagram already incorporated into the calculation.
Here, “processed” means that the corresponding crossing or graph connection has already been incorporated into the running state. Processing a crossing means applying its three local choices from Eq. (4) to every state currently stored, multiplying by the appropriate local weight and updating the connections among the resulting open arc ends. Processing continues until every local object has been incorporated. The calculation can therefore be summarized as
The aggregation of partial states by unresolved boundary data has analogues in dynamic-programming algorithms for knot polynomials, including the tree-decomposition algorithm for HOMFLY-PT [69]. Here, however, the stored boundary data and all local updates are those required by the Yamada state sum in Eq. (5) and its crossing-free graph contribution in Eq. (6). If the input diagram has disconnected components, the calculation is performed on each component separately and the resulting Laurent polynomials are multiplied, hence we describe one connected component below.
What is stored after part of the diagram has been processed. Suppose that the current processing boundary contains the open arc ends . The detailed geometry of the already processed region is no longer needed. What matters for future steps is which of these open ends have already become connected to one another through paths lying entirely inside the processed part.
Two open ends therefore need not be joined by a single edge to be regarded as connected. They are in the same stored component whenever a path through the processed region already joins them. The algorithm records this information by
Thus records a partition of the currently open arc ends into connected components. The numerical labels themselves carry no information; only equality or inequality of the labels matters. They are therefore renumbered canonically from left to right, beginning with 0.
For example,
means that and have already been joined by some path through the processed part, while and have been joined through another processed component. The state does not record the actual paths or which earlier side-smoothing, top-smoothing or vertex choices created them. In particular, the first and third entries being equal means only that the processed portion already contains a path between them.
This is the information that remains relevant because every later local operation acts on the processed region only through these open ends. Suppose, for example, that two different partial Yamada-resolution histories have both reached the same four open ends and both leave
The first history may have reached this connectivity through one sequence of side, top and vertex resolutions, while the second may have reached it through a completely different sequence. Their accumulated Laurent-polynomial contributions can therefore be different; denote them by and .
Nevertheless, everything that remains to be processed sees exactly the same boundary data in the two cases. In both histories, the same four arc ends are present, is already connected to , and is already connected to . Any later crossing resolution, graph-vertex connection or edge inclusion therefore changes the two states in the same way. The future calculation cannot distinguish which earlier sequence produced the connectivity.
Consequently, the two histories do not need to be propagated separately. Their accumulated polynomial contributions can be added immediately and associated with the single boundary state,
This is simply an early collection of terms that would otherwise remain separate until the final sum in Eq. (5). If the continuation of the diagram acts identically on both histories, propagating and separately and adding them at the end gives the same result as adding them first and propagating their sum.
More generally, at every stage the algorithm stores a table
where specifies the connectivity of the currently open arc ends and is the sum of the exact Laurent-polynomial contributions of all partial histories that produce that same boundary connectivity. Thus one stored state can represent many different prefixes of the complete resolution tree in Eq. (5). The histories are combined only after they have become indistinguishable to every operation that remains unprocessed.
This also clarifies the distinction between the repeated outcomes in Supplementary Fig. 5 and the state compression used in larger calculations. In that figure, different complete assignments can be seen to produce repeated final polynomial outcomes. The running algorithm uses the stronger intermediate criterion above: two histories can be combined before completion whenever they expose the same open arc ends with the same connectivity and have already accumulated all algebraic factors arising from their different processed histories.
Incorporating a crossing. When a crossing is processed, its four incident arc ends are introduced into every currently stored boundary state. The three alternatives in Eq. (4) are then applied. For each incoming state,
- the side smoothing reconnects the four incidences according to the side pairing and multiplies its accumulated contribution by Y;
• the top smoothing uses the complementary pairing and multiplies the contribution by ;
• the vertex resolution joins the four incidences through a graph vertex and has unit weight in the local crossing relation.
The algorithm immediately computes the new boundary connectivity and merges any branches that have become identical according to Eq. (S7). The vertex resolution must also be connected to the second part of the Yamada calculation. Although its local crossing weight in Eq. (4) is 1, it creates a graph vertex in the resolved graph . Every vertex of contributes through the factor in Eq. (6). Thus a vertex created by a crossing resolution contributes one factor -1 when the graph-polynomial part of the calculation is incorporated. The local weight 1 and the graph-polynomial factor -1 arise from different formulas and must not be conflated.
After the three local branches have been created and their connectivity has been updated, states with identical boundary connectivity are immediately combined. Thus the calculation still contains all three Yamada choices from Eq. (4), but it does not retain two separate copies of a future calculation once their processed parts have become equivalent from the perspective of the unprocessed diagram.
Incorporating the crossing-free graph contribution. After all crossings in a complete state s have been resolved, the direct state sum would require the evaluation of the crossing-free graph polynomial
from Eq. (6). For each physical graph edge, the edge-subset sum in Eq. (6) introduces two possibilities: the edge is either excluded from F or included in F. If it is excluded, the connectivity is unchanged and the contribution is multiplied by +1. If it is included, the contribution acquires the factor -1 from and the connected components containing the two endpoints are joined. These include/exclude updates are applied directly within the running connectivity calculation, so the complete graph need not be constructed first.
The stored connectivity makes it possible to determine immediately whether including the edge merely joins two components or creates a new cycle. If its two endpoints belong to different components of the current state, including the edge joins those components and contributes only the factor -1. If the two endpoints are already connected by a path through the processed part, including the edge closes an additional cycle. In that case the cycle rank in Eq. (6) increases by one and the factor
is inserted at that moment. The complete contribution of such an included edge is therefore
In this way, the factor is accumulated one completed cycle at a time. The final value of does not need to be stored explicitly: every increase in cycle rank has already contributed its corresponding factor. Likewise, the signs associated with included edges and graph vertices are inserted when those objects are processed. The state weight therefore contains all algebraic information from the processed portion that is needed by Eqs. (5) and (6).
Removing open ends that can no longer affect the calculation. The set of open arc ends changes as processing advances. An open end is needed only while it remains incident, through the original PD connectivity, to some object that has not yet been processed. Once an open end lies entirely inside the processed region and cannot participate in any later crossing, vertex or edge operation, it can no longer affect the remainder of the state sum and is removed from the boundary description.
For example, suppose five open ends have the connectivity
This means that and are already connected, and are connected through another component, and belongs to a third component. If and no longer connect to any unprocessed object, both ends can be deleted from the boundary. The remaining labels are . Since the numerical labels themselves are arbitrary, this state is canonically renumbered as
This removal can reveal additional equivalences. Two histories that previously had different boundary states can become identical after their finished ends are discarded. Their accumulated Laurent-polynomial contributions are then combined according to Eq. (S7). Repeating this operation ensures that the stored state describes only the portion of the processed diagram that can still influence the unprocessed calculation.
Splitting a high-degree graph vertex into smaller connection steps. A graph vertex of degree d requires all d of its incident arc ends to belong to the same connected component in the resolved graph. Introducing all d incidences simultaneously can cause many open ends to be present at once, even though the required final connectivity is simple. The algorithm therefore enforces the same identification through a deterministic sequence of smaller connection steps, each involving at most three arc ends.
These helper connections are bookkeeping operations only. They do not create additional physical graph edges and do not alter the graph represented by the PD code. Their purpose is to impose the original degree-d vertex connection without exposing all of its incident arc ends simultaneously.
The graph-polynomial factor must nevertheless remain exactly that of the original vertex. The factor in Eq. (6) supplies one factor -1 for that graph vertex, regardless of how many helper steps are used internally. One of the smaller connection steps therefore carries this factor -1, while the remaining helper steps have weight +1.
If a helper identification joins two arc ends that are already connected through the processed state, the identification closes a cycle and contributes the corresponding factor . It does not receive the additional physical-edge sign -1 because a helper connection is not an edge belonging to the subset F in Eq. (6). The sequence therefore produces the same final connectivity and the same polynomial contribution as processing the original degree-d vertex directly.
Why the processing order matters. The compression above removes dependence on the number of complete histories that have already collapsed to the same boundary state, but the number of possible distinct states still depends strongly on how many open arc ends are present simultaneously. With only a few open ends there are relatively few possible partitions into connected components. As the number of open ends grows, many more distinct connectivities can occur and fewer partial histories can be combined.
This is why the computational cost is controlled not only by the total crossing number in Eq. (8), but also by the number of connections exposed simultaneously during the running calculation. The main text summarizes this dependence after Fig. 3, and the projection-selection procedure in Supplementary Note 2.A uses the same quantity when deciding whether a slightly more crossing-rich projection may nevertheless be easier to evaluate.
The algorithm therefore chooses the order in which crossings and graph-vertex connection steps are processed. It preferentially continues from objects already adjacent to the processed region, so that existing open connections are closed before many unrelated new ones are introduced. For an unprocessed step j, let denote the number of its connections to already processed steps, the number of its connections to still-unprocessed steps and the number of its incident arc ends. The first step is chosen with the smallest total number of connections, using smaller to break ties. Subsequent steps are ordered according to
The entries are compared from left to right. The first term penalizes a step that is disconnected from the currently processed region. The following terms prefer steps that close existing connections while opening fewer new ones. The remaining entries make the order deterministic when the earlier criteria are tied.
For every candidate processing order, the algorithm records the maximum number of open arc ends encountered, together with the largest number remaining after a step and the sum of these post-step counts. For a diagram with at least 12 crossings whose initial order reaches at least 12 simultaneous open ends, up to 16 alternative deterministic starting steps are tested. An alternative is retained only when it lowers the maximum number of simultaneous open ends by at least two. The projection refinement described in Supplementary Note 2.A uses the same criterion: for a difficult calculation, a projection containing slightly more crossings can be preferred when its PD connectivity can be processed with substantially fewer open ends at once.
After every crossing, graph vertex, helper connection and physical graph edge has been processed, no open arc ends remain. At that point all complete crossing-resolution and edge-subset contributions represented by Eqs. (5) and (6) have been accumulated into the final state. Its Laurent-polynomial contribution is therefore the raw Yamada polynomial . In this sense, the running table is only an intermediate organization of the terms in the exact state sum; once the boundary becomes empty, their sum is the same raw polynomial that would have been obtained by explicit enumeration.
The calculation first uses checked 64-bit integer coefficients. If any coefficient exceeds that range, the same exact calculation is repeated with arbitrary-size integers, without approximation or truncation. Only after the raw polynomial has been completed is the normalization in Eq. (7) applied to obtain . Thus the complete computational sequence is
with the state combination changing only how the exact terms are organized and summed, not the Yamada relations being evaluated.
Supplementary Note 3.D | Using Yamada values to test family formulas
The importance of this scaling extends beyond faster evaluation of individual knotted graphs. The published formulas above exemplify the traditional direction in which family-specific mathematics is first used to derive a recurrence or closed form, after which large family members become inexpensive to evaluate [32, 33, 40]. A general exact algorithm allows the order of investigation to be reversed: a family-specific recurrence need not be known before topological data are generated. The scaling result in Fig. 3 therefore serves two roles. It validates the general exact algorithm against independently known mathematics at a scale far beyond explicit enumeration of the full resolution tree, and it provides the data regime used for the family-scale investigations developed in Supplementary Note 7.
Supplementary Note 4 | Independent validation of knotted-graph construction, projection and Yamada evaluation
Knotted-graph construction is tested against known volumetric seeds; projection and PD construction are tested through multi-view consistency and planar references; and exact algebra is tested against published Yamada identities and closed-form formulas [26, 32, 33] (Fig. 2a–c). Matching each stage to an independent target prevents an error in one interface from being hidden by agreement elsewhere.
Supplementary Note 4.A | Algebraic and projection checks
The Yamada implementation is tested at four complementary levels, separating graph-polynomial identities, published closed-form families [32, 33], crossing-dependent relations and three-dimensional projection.
(1) Graph-level algebra. The algorithm reproduces the tested tree family , cycles , bouquets and theta graphs , together with the isthmus and one-point-union identities, using the Yamada and edge-replacement relations in Refs. [26, 33]. A planar value and additional cubic-graph values are checked against Ref. [32]. The Negami calculation is independently compared with Negami's defining edge-subset polynomial [46], and its Yamada specialization is compared with the direct graph calculation.
(2) Published closed-form families. The three structured families in Fig. 3 provide independent algebraic references because their Yamada polynomials were derived analytically. For the family in Fig. 3a,d,g, we use Theorem 2 of Ref. [32],
For the edge-replaced families in Ref. [33], defining , Theorem 5.1, Corollary 5.2 and Example 5.4 of that work give the expression used for Fig. 3b,e,h,
For the corresponding edge-replaced theta family in Fig. 3c,f,i,
(b)

(c)

(d)

(e)

(f)

(g)

(h)

(i)

(j)

(k)

(l)

(m)

(n)

(o)

(p)

(q)

(r)

(s)

(t)


Supplementary Fig. 6 | Knotted-graph construction from volumetric inputs is tested against known generating graphs. (a–t) Representative outputs from the recovery chain in Eq. (S18), with the normalized Yamada invariant evaluated on each resulting graph. The benchmark uses a voxel grid, tube radii of at least four voxels, and thickness and safety factors of 0.90. Crossing-rich cases constitute approximately 60% of the random ensemble and contain at least two verified projected crossings, with centerline separation exceeding 2.4 tube radii at each prescribed crossing. The input acceptance uses the digital homology condition in Eq. (S19).
Every displayed KnottedGraph benchmark point in Fig. 3 agrees exactly with its corresponding literature expression, including the largest tested structured diagrams with 500 crossings. This establishes the evaluated scale for these structured families. It does not imply that every diagram with the same crossing number has comparable cost.
Topoly [6] is used as an external software comparator only where both implementations pass the same published reference. The external software comparison is reported in Supplementary Note 4.C.
(3) Crossings and mirroring. Crossing-dependent tests use a planar theta graph, a crossed theta diagram and its mirror. The expected one-crossing factor is checked against the behavior used by Peddada et al. [8].
(4) Projection invariance. Multiple regular projections are generated for each fixed subcubic three-dimensional spatial graph G. Each accepted view is processed independently through crossing detection, edge over/undercrossing determination and PD construction. All accepted projections of the same subcubic spatial graph must give the same normalized invariant, , even when their crossing numbers and raw diagram polynomials differ. Planar-reference cases are additionally compared with the independently evaluated crossing-free graph polynomial. The tested catalogue includes theta, , triangular-prism, and cube-type examples.
These checks separate errors in the algebraic calculation from errors in the three-dimensional-to-diagram conversion.
Supplementary Note 4.B | Handlebody-knotted-graph construction tests
Here we test whether a knotted graph can be constructed from a volumetric representation. We use an inverse benchmark in which a known knotted graph is thickened and voxelized before the graph is recovered,
Connected-component labeling and the lattice Euler characteristic are computed with SciPy and scikit-image [63, 70], using the digital Euler-number convention of Ohser, Nagel and Schladitz [71]. Supplementary Fig. 6 shows representative outputs from the 4,400-case program, ranging from simple loop arrangements to crossing-rich embeddings. The polynomial beneath each graph is a spatial-embedding comparison quantity, not a visual measure of construction quality. All 4,400 cases pass the stated input and graph-level recovery checks, and all 4,400 seed–output normalized Yamada comparisons agree. The benchmark procedure is as follows:
Inverse handlebody-to-graph construction benchmark
-
Generate a known knotted graph. Construct a connected, bridge-free and subcubic knotted graph . At every prescribed crossing, the three-dimensional centerlines must satisfy , and the package's standard xy projection must resolve the prescribed edge over/undercrossing information.
-
Thicken and voxelize the graph. First estimate the minimum non-contact separation between distinct parts of the knotted graph. Edge curves are resampled densely for this estimate, with neighborhoods of shared vertices excluded when comparing incident edges and the tube radius is chosen. The regular neighbourhood is defined as
A cubic grid is placed around the complete embedding with an additional margin of . For every piecewise-linear edge segment , the closest point to a voxel center is computed as
The voxel is assigned to whenever for at least one edge segment. Thus the binary input is constructed directly from the geometric -neighbourhood of the known knotted graph; no pre-existing surface or mesh is used.
- Check the voxelized input. The voxelized object is accepted only when
and its tube radius is at least four voxels. This checks the measured component, cycle and cavity counts against the seed. It is a necessary consistency test, not a proof that the voxel object is a manifold or an ambient-isotopic regular neighbourhood.
-
Construct the knotted graph. Apply the KnottedGraph pipeline to to obtain .
-
Check recovered graph connectivity. The graph-level recovery check passes when
Abstract isomorphism between and is recorded separately as an additional diagnostic.
- Compare normalized Yamada invariants. Compute the normalized Yamada invariant independently for the original and resulting knotted graphs,
Whenever both evaluations succeed, the polynomial comparison passes only if .
- Assign the benchmark result. A case passes the recovery checks when the voxelized input passes the digital-homology and thickness conditions and the resulting graph passes the graph-level conditions above. Yamada preservation is recorded as a separate spatial-embedding check whenever both polynomial evaluations are available. A failed applicable condition is retained as a failed check, and an unavailable polynomial remains a separate outcome. Equal polynomials are not a complete embedding-equivalence certificate.
The Topoly distribution is right-censored by the configured runtime limit: completed evaluations contribute to the histogram and its summary statistics, whereas non-completed cases are retained separately by status. The KnottedGraph projection and Yamada timings are available for all 4,400 cases. The marginal software distributions are therefore not interpreted as a paired speedup measurement. Pointwise software ratios are reported separately in Supplementary Note 4.C using the structured published families in Fig. 3.
Skeletonization

(b)
Graph extraction
(c)
Edge contraction
(d)
Leaf removal

(e)
Edge simplification
(f)
Edge smoothing
(g)
Projection selection

(h)
KnottedGraph Yamada
(i)
Topoly Yamada
Supplementary Fig. 7 | Runtime distributions for the KnottedGraph stages of the handlebody-to-graph construction benchmark. Histograms show per-case execution times for the 4,400 curated cases in the inverse benchmark of Eq. (S18). The plotted stages correspond to the graph construction, cleanup, projection-selection and invariant-evaluation operations described in Supplementary Note 1.C, Supplementary Note 2 and Supplementary Note 3. (a) Skeletonization of the filled voxel volume to a one-voxel-wide backbone, corresponding to Supplementary Fig. 2c; (b) multiscale extraction of the raw knotted graph from the voxel skeleton, corresponding to Supplementary Fig. 2d; (c) short-edge contraction, corresponding to Supplementary Fig. 2g; (d) leaf removal, corresponding to Supplementary Fig. 2e; (e) degree-two edge simplification, corresponding to Supplementary Fig. 2f; (f) geometric edge smoothing by Ramer–Douglas–Peucker simplification, corresponding to Supplementary Fig. 2h; (g) selection of a regular projection and associated diagram for the recovered knotted graph; (h) normalized Yamada-invariant evaluation on the recovered graph using the exact KnottedGraph calculation described in Supplementary Note 3; and (i) the corresponding Yamada calculation using Topoly on the same selected PD codes. Completed Topoly evaluations are shown in the histogram; timeout and other non-completed cases are excluded from the completed-time statistics and reported separately. The horizontal axis gives time in seconds and the vertical axis gives the number of benchmark cases. Solid vertical lines mark the mean runtime for each stage, and dashed vertical lines mark the 95th percentile.
Supplementary Note 4.C | Timing protocol
Two timing protocols are used for the results reported in Fig. 3, Table 1 and Supplementary Fig. 7. The structured-family benchmark isolates invariant evaluation on fixed PD inputs, whereas the handlebody benchmark reports stage-wise runtimes across the full 4,400-case construction workload.
The distributions in Supplementary Fig. 7 characterize the computational cost of the successive stages of the handlebody-to-graph pipeline. Panels (a–f) report skeletonization, multiscale graph extraction and the graph-cleanup operations; panels (g,h) report projection selection and exact KnottedGraph Yamada evaluation; and panel (i) reports the corresponding Topoly calculation on the same selected PD codes. The displayed mean runtimes obey the approximate ordering
The observed ordering follows the size and complexity of the representation handled at each stage. Skeletonization acts on the full voxel volume, while extraction and cleanup operate on the much smaller graph representation. Projection remains comparatively costly because it requires geometric crossing detection and validity checks across candidate views. The exact KnottedGraph Yamada calculation is smaller in this benchmark because equivalent partial resolution states are merged during evaluation, and leaf removal is the simplest graph-level operation. This ordering is specific to the tested benchmark.

(b)

(c)
(d)

λ
λ
(e)
λ
Supplementary Fig. 8 | Hamiltonian-derived parameter scans across five interpolating families. The displayed colors are postprocessed output labels and can mix spatial evaluations with abstract fallback values. Black curves separate displayed labels; they are not established Lifshitz boundaries. (a) Hopf link → trefoil; (b) Hopf link → Solomon link; (c) unknot → trefoil; (d) unknot → Solomon link; (e) trefoil → cinquefoil. Each panel samples the interpolation and energy axes over the range used for that family. The finite-domain and postprocessing conventions are specified in Supplementary Note 5.A.
Supplementary Note 5 | Parameter sweeps of volumetric geometries
The computational efficiency above supports repeated application of the same construction and invariant interfaces across a parameter space. For a family of volumetric regions , we use the common notation
where is the resulting knotted graph and O records the quantity used for that analysis: an admissible spatial-graph invariant, a fixed-diagram polynomial, an abstract graph summary or an unavailable result. A region with one recorded label need not be a region of equivalent analytic solids. The displays below illustrate the parameter-scan interface; their grouping and filtering are specified before any physical interpretation. The construction, projection and Yamada stages are those established in Supplementary Notes 1.B and 1.C, Supplementary Note 2 and Supplementary Note 3; here we report the parameter-dependent outputs obtained by repeated application of those stages.
Supplementary Note 5.A | Volumetric regions in momentum space in condensed matter contexts
A physical example is provided by finite-energy Fermi volumes, defined in momentum space, which is Fourier conjugate to the real-space lattice in condensed matter. Lattice couplings and periodic driving can generate intricate momentum-space nodal links [72], while higher-dimensional circuit constructions provide access to nodal-boundary Seifert surfaces [73].
Changes in Fermi-surface topology define Lifshitz transitions [74, 75], and experimentally accessible controls such as strain [50], pressure [51] can continuously deform a material Hamiltonian and move these transition boundaries. Composition-driven topological band evolution [52] provides another example of a tunable Hamiltonian, without identifying that band transition with a particular Fermi-surface Lifshitz event. The finite-energy Fermi-volume knotted-graph construction is introduced in [14]. Here we use the same geometry-to-graph interface to organize finite-window calculations across the corresponding two-parameter scans.
The analytic benchmark models combine the complex-variable nodal-knot construction of Bi et al. with the Bloch lattice map used by Lee et al. [10, 11]:
(S22)
with
The recovered endpoint constructors use and , except for the Solomon endpoint, which uses the literal value (not exactly ). A path to that endpoint therefore also changes the endpoint map parameter. The unknot, Hopf link, trefoil, Solomon link and cinquefoil correspond to , , , and , respectively. The corresponding interpolations are Hopf link trefoil in Supplementary Fig. 8a, Hopf link Solomon link in Supplementary Fig. 8b, unknot trefoil in Supplementary Fig. 8c, unknot Solomon link in Supplementary Fig. 8d, and trefoil cinquefoil in Supplementary Fig. 8e.
Since the positive-energy band is
the filled Fermi region up to energy E, restricted to the sampled momentum-space domain specified below, is
where is the positive-energy dispersion of
The calculation uses a finite sampling of . Opposite faces are not periodically identified. The presence of both and means that is not a periodic fundamental interval for the full field. Boundary-touching inputs are consequently finite-window objects.
For the two real components , of , the computational constructor also uses the auxiliary non-Hermitian matrix . Its eigenvalues are . Thus its ideal purely imaginary-spectrum region has the geometric inequality used in Eq. (S25), although the auxiliary Hamiltonian itself is not Hermitian.
The five scans sample a common interpolation grid in together with family-dependent energy ranges used in the corresponding panels of Supplementary Fig. 8. The scan can substitute an abstract graph polynomial when a spatial evaluation is unavailable. The displayed labels are postprocessed for clearer view.
A verified Lifshitz boundary would provide a natural point of comparison with density-of-states, transport, thermodynamic and superconducting responses [76–79]. The same construction extends directly to material-derived multiband Hamiltonians. A microscopic Hamiltonian parameter can play the role of , and E defines a volumetric region from a selected band-energy or interband-gap condition; constructing across this plane then organizes its parameter-dependent graph outputs. For material scans, the program loops over first because changing the energy or gap threshold does not change the Hamiltonian at that fixed . The Hamiltonian is therefore diagonalized once for each sampled , and the resulting band energies are reused for every energy or gap threshold on the second scan axis. Only the spectrum for the current is kept in memory, and the records are returned in the public output layout. This avoids repeating the same diagonalization many times without storing spectra for all sampled values. Their interpretation as source-topology labels requires the corresponding graph construction and equivalence checks.
Supplementary Note 6 | Geometric preconditioning of difficult embeddings
Even after a spatial graph has been constructed, its geometry can make a useful planar diagram difficult to obtain. A folded edge may take long detours, pass close to other edges or contain many small bends, all of which can obscure the crossing structure in projection. Geometric preconditioning addresses this problem by moving the graph's curves in three dimensions before projection (Fig. 2f). It optimizes the coordinates along the edges while retaining the graph's vertices and incidence relations. The resulting curves provide a geometric representation for visualization and topological analysis.
The nonlocal repulsion is based on the tangent-point energy introduced by Buck and Orloff [80] and the computational approach of Yu, Schumacher and Crane [30]. Using Schumacher's Repulsor library [81], KnottedGraph converts graph edges to sampled curves, constrains the graph vertices, checks the geometric updates and maps the relaxed curves back to the graph for projection and invariant evaluation.
Supplementary Note 6.A | Protein-derived theta graphs
Supplementary Fig. 9 illustrates the workflow with three protein-derived graphs, labelled by their source structures 1AOC, 3ULK and 5OSQ in the RCSB Protein Data Bank [1]. Their initial geometries are shown in Supplementary Fig. 9a, Supplementary Fig. 9g and Supplementary Fig. 9m, respectively. A graph has two vertices joined by three internally disjoint paths. The red, blue and green curves identify those three paths throughout each row. Each path can combine backbone portions with selected bridges, so the colours track path identity across the processing stages. These constructions select a graph from each protein’s geometry and connections; the complete molecular and crosslink networks contain additional structure.
The protein examples supplied with the library use chain A of the first structural model. Backbone portions follow the ordered Cα coordinates. Selected bridges connect these portions directly or through a metal-ion coordinate. For example, the 3ULK construction joins residues D217 and E393 by three routes: the intervening backbone, a bridge through Mg498, and the remaining selected backbone portions with an added closure. The 5OSQ construction similarly joins D437 and C469 using a backbone route, a route through the selected C376–C469 disulfide bridge, and a longer route through Ca503, Ca504 and a closure. The 1AOC construction combines selected backbone portions and cysteine bridges into three paths, with a closure in one path. An artificial closure joins selected backbone endpoints to complete one of the paths. This modelling connection is specified separately from the structure-derived bridges. Its coordinates are part of the input embedding, and the subsequent analysis is conditional on that closure choice.
Each path is represented by a polyline. The two graph vertices are shared endpoints of all three polylines, and intermediate samples discretize each path. Their assignment to the original graph edge is retained throughout relaxation. Subdivision that retains every original corner leaves the path unchanged. Resampling that replaces corners changes the geometry, including when it increases the sample count, and requires validation at that stage. The checks on subsequent solver steps begin from the resulting sampled embedding. Sample removal by checked shortcuts is described below.
In these graphs, the branch vertices have degree three and the intermediate samples have degree two. The selected graphs are thus subcubic, and their normalized Yamada polynomials are ambient-isotopy invariants [25, 26].
Supplementary Note 6.B | Unfolding, compaction and smoothing
Each row of Supplementary Fig. 9 follows the selected paths from their protein-derived geometry through three relaxation stages and then to a planar diagram. The stages emphasize separation, length control and local regularity, respectively.
Unfolding. Nonlocal repulsion opens crowded regions by moving nearby strands apart, giving the curves room to move before substantial shortening is attempted. The unfolded 1AOC, 3ULK and 5OSQ geometries are shown in Supplementary Fig. 9b, Supplementary Fig. 9h and Supplementary Fig. 9n, respectively. Here, unfolding describes a geometric layout operation rather than a simulation of molecular unfolding. The motion is subject to the strand-crossing checks specified in Supplementary Note 6.D.
Compaction. Length control draws in long detours present in the initial geometry or introduced by the opening stage. Repulsion remains active during shortening to maintain strand separation. Compaction shortens the geometric paths while retaining every graph edge and its endpoints. The corresponding compacted geometries are shown in Supplementary Fig. 9c, Supplementary Fig. 9i and Supplementary Fig. 9o.
Smoothing. A local bending penalty reduces residual polyline oscillations. A separate clearance penalty can encourage enough separation for curves drawn as tubes to remain visually distinct. The smoothed geometries are shown in Supplementary Fig. 9d, Supplementary Fig. 9j and Supplementary Fig. 9p. The smoothed curves are then projected, their over-under crossings are recorded, and the resulting PD code is evaluated. The corresponding planar diagrams are shown in Supplementary Fig. 9e, Supplementary Fig. 9k and Supplementary Fig. 9q, with their PD codes and Yamada polynomials in Supplementary Fig. 9f, Supplementary Fig. 9l and Supplementary Fig. 9r. The objective acts on the three-dimensional curves; projection selection is performed after relaxation.
| Initial | Unfolding | Compacting | Smoothing | Planar diagram | PD / Yamada code |
|---|---|---|---|---|---|
| (a) 1AOC COAGULOGEN | (b) | (c) | (d) | (e) | (f)PD: V[3,0,8]; V[2,7,8]; X[7,4,6,3]; X[1,5,0,6]; X[5,1,4,2] |
| (g) 3ULK KETOL-ACID REDUCTOISOMERASE | (h) | (i) | (j) | (k) | (l)PD: V[10,0,3]; V[10,9,2]; X[2,7,1,6]; X[8,5,7,4]; X[5,0,6,1]; X[3,8,4,9] |
| (m) 5OSQ ZP3 ZP-N DOMAIN | (n) | (o) | (p) | (q) | (r)PD: V[0,8,7]; V[6,7,8]; X[2,5,1,4]; X[3,0,4,1]; X[6,3,5,2] |
Supplementary Fig. 9 | From a crowded protein-derived embedding to a readable graph diagram. The rows show selected graphs derived from 1AOC (a–f), 3ULK (g–l) and 5OSQ (m–r). Red, blue and green track the three paths between the two branch vertices; a path may contain both backbone portions and selected bridges. The initial geometries (a, g, m) are followed by unfolding (b, h, n), compaction (c, i, o) and smoothing (d, j, p). These operations open close approaches, shorten detours and regularize the curves, respectively, while retaining the three paths and their common endpoints. The planar diagrams (e, k, q) retain depth information at crossings, and the last column (f, l, r) gives the corresponding PD codes and Yamada polynomials.
Supplementary Note 6.C | Tangent-point-energy relaxation of knotted graphs
Let denote the sampled curve vertices and their line segments. A segment has length , midpoint , unit tangent , and normal projector . The projector extracts the part of a displacement perpendicular to the segment, making the interaction sensitive to both segment separation and tangent direction.
The symmetric midpoint interaction is
Each unordered pair of distinct segments is counted once; the two numerator terms account for the two tangent directions. Self-pairs are omitted. In the Repulsor discretization, neighbouring segments that share a vertex also contribute to the midpoint interaction. Collision and tube-clearance checks instead use pairs with no shared vertex, allowing the intentional contacts at graph junctions.
Supplementary Eq. (S27) describes the basic midpoint kernel. The native calculation uses Repulsor's TangentPointEnergy0, with hierarchical far-field evaluation and adaptive treatment of close, non-neighbouring segments [81]. This evaluates the interactions through a spatial hierarchy. The midpoint kernel differs from the endpoint-based trapezoidal quadrature of Yu, Schumacher and Crane [30]. The default exponents are , .
Length control uses the sum of squared segment lengths,
which encourages shorter segments. Unlike the total arc length , this quantity changes when a straight segment is subdivided. Local smoothing uses the second-difference penalty
where contains only degree-two samples and , are their two neighbours. Restricting the sum to these samples gives each term a unique pair of neighbours and excludes branch vertices and endpoints. Both penalties depend on the sampling density and coordinate scale, which are recorded together with their weights.
For tubes of display radius and a desired gap , the optional clearance term is
where N consists of unordered segment pairs with no shared vertex and is their minimum Euclidean distance. This soft penalty encourages a centreline separation of ; crossing prevention is handled by the motion checks. The objective combines the backend tangent-point energy and these penalties with non-negative weights, . The weights set the emphasis of each stage. The same formulation also supports a single relaxation with fixed weights. Because crossing number is absent from the objective, a minimum-crossing projection is not guaranteed.
Supplementary Note 6.D | Relaxation and topology checks
Edges can pass through one another during an update even when its initial and final configurations are free of self-intersections. The solver checks the intervening motion of each proposed update. Starting from a valid embedded polyline network, it computes a descent direction using the tangent-point metric and sets an initial step to a fraction of Repulsor's maximum-safe-step estimate. A trial is accepted when both the motion check and an Armijo energy-decrease test pass; otherwise the step is halved and tested again.
During a trial step, every sample moves linearly from its old to its proposed position. For each pair of segments with no shared vertex, the additional motion check first tests whether their swept bounding boxes are separated. For the remaining pairs it finds candidate contact times from the cubic coplanarity condition of the four moving endpoints and tests segment distances at those times, as well as at the step endpoints and midpoint. A contact within the specified tolerance rejects the step. Degenerate coplanarity cases not excluded by the bounding-box test are rejected conservatively. The resulting verification is numerical, with its contact tolerance defined in the input coordinate units.
All original graph vertices are pinned by default; interior curve samples can move. Optional pinned collar samples are the first few interior samples on every incident edge. Fixing a vertex preserves its position, whereas also fixing a collar preserves a local piece of each incident edge. Pairs sharing a sample are omitted from the additional motion check because their common endpoint is intentional. For higher-valence graphs, the local junction geometry therefore requires separate constraints and validation. Invariant comparisons in that setting also require a common rigid-vertex structure.
Per-step motion checking is enabled by default. When intermediate states are saved, an optional independent verifier replays the successive swept motions; a failed replay raises an error. Static clearance measurements at the initial, relaxed and final-simplified states report the geometric separation at each stage. They complement the motion checks by showing how strand separation changes during the relaxation.
Simplification is checked separately from relaxation. Replacing the two segments and by sweeps the triangle with vertices . The decimator accepts this shortcut only when its conservative clearance tests against segments sharing none of pass and its pinning constraints are respected. Configurations at shared vertices require the local junction constraints described above. Related intersection-tested polygonal reductions have also been used in protein knot-polynomial workflows [82].
Supplementary Note 6.E | Mapping relaxed curves back to the knotted graph
After relaxation and any accepted simplification, the retained sample-to-edge mapping transfers the coordinates to a copy of the original graph. Vertex labels, edge keys and non-geometric attributes are preserved; positions and edge polylines are updated. The result enters the usual projection search, crossing detection, PD-code construction and Yamada evaluation, with each projected arc still associated with its original graph edge.
The retained mapping establishes the correspondence of vertices and edges before and after relaxation. Swept-motion and shortcut checks assess the geometric changes along that correspondence. For subcubic graphs, agreement of the normalized Yamada values supplies a further consistency check; polynomial equality alone is insufficient to establish isotopy because distinct embeddings can share an invariant. Failed or resource-limited evaluations are recorded as unresolved. The output is a relaxed geometric representative in the same graph data structure, ready for the standard projection and invariant pipeline.
Supplementary Note 6.F | Solver settings and reproducibility
Supplementary Table 3 lists the default configuration of the native solver. Repulsion is active by default; compaction, bending and tube clearance are enabled by setting their weights. The solver performs at most 100 iterations and terminates earlier when no acceptable descent step can be found.
Supplementary Table 3 | Default native relaxation settings. Distances and geometric tolerances refer to the supplied coordinate units. The inner-solve tolerance controls the iterative calculation of the descent direction.
| Control | Default | Meaning |
|---|---|---|
| Tangent-point exponents | Distance and normal-displacement powers. | |
| Objective weights | ; other penalties | Compaction, bending and tube clearance are opt-in. |
| Outer iterations | At most 100 | Maximum number of attempted descent iterations. |
| Safe-step fraction | 0.95 | Initial fraction of the backend's safe-step estimate. |
| Line search | 12 backtracking reductions;Armijo coefficient | A rejected trial is halved. |
| Metric solve | At most 60 iterations; tolerance | Controls the iterative descent-direction solve. |
| Swept-motion check | Enabled; tolerance | Checks segment pairs with no shared sample. |
| Graph constraints | Original vertices pinned; collar depth 0 | Local incident-edge directions are not pinned by default. |
| Independent replay | Off | Requires both saved states and explicit verification. |
Reproducing a relaxation requires the input graph, closure coordinates, sample counts, coordinate scale, stage weights, pinning choices and simplification settings. The run records include the graph–curve mapping, solver parameters, accepted-step history, static clearance summaries, total curve length and bounding-box scale. Intermediate states and the independent replay result are saved when requested. The Repulsor source revision is specified in the software reference [81]. Together, the input, settings and geometric records allow the relaxed curves and their projected diagrams to be traced back to the original graph.
Supplementary Note 7 | Inferring and testing Yamada family formulas from Yamada data
The preceding sections establish scalable exact Yamada evaluation across knotted-graph families. This enables a second use of the calculation: exact invariant values can serve as data from which family-level mathematical structure is inferred. Instead of evaluating a family only after its analytical law is known, we consider the inverse problem of reconstructing candidate formulas from finitely many evaluated family members.
Existing Yamada-polynomial family formulas have been derived from family-specific mathematical structure. An explicit formula for the family is given in Ref. [32], while formulas for spatial graphs obtained by replacing the edges of cycle, theta and bouquet graphs by spatial parts are derived in Ref. [33]. These relations have also been used in the study of Yamada-polynomial roots [83]. Transfer-matrix constructions for repeated layers of symmetric spatial graphs are developed in Ref. [40]. Further analytical relations connect the Yamada polynomial to knot and link invariants, including the Jones polynomial of associated links of -curves [84] and relations among Yamada, Jaeger and Jones polynomials for spatial -graphs and their subgraphs [85]. These results begin from a specified family construction, recurrence, transfer structure or invariant relation and derive the corresponding polynomial law. They do not provide a general procedure for starting from exact Yamada values when that family-specific algebra is not known in advance.
Recent AI-assisted mathematics provides an evaluation-guided setting for this inverse direction. FunSearch combines LLM-generated proposals with systematic evaluation to obtain new mathematical constructions [34], while AlphaEvolve uses an evaluation-guided evolutionary loop for scientific and algorithmic discovery [36]. Related work reports cases in which finite computational data are generalized to candidate formulas across mathematical problem classes [37], while AlphaProof illustrates the complementary role of machine-verifiable reasoning [38].
Here we apply this data-to-structure strategy to topological-invariant data. KnottedGraph first generates exact Yamada polynomials for selected members of a parameterized knotted-graph family. An LLM then uses only a designated discovery subset to propose candidate recurrences, closed forms or transfer structures. A retained proposal is converted to an explicit symbolic formula or operator representation before additional family members are evaluated and used as held-out tests. The methodological novelty is therefore the direction of inference: candidate family algebra is reconstructed from exact Yamada-polynomial data without prescribing the family-specific recurrence, transfer representation or closed form in advance.
Supplementary Note 7.A | LLM-assisted conjecture generation and held-out verification
The protocol is shown in Fig. 4a. A discovery set provides invariant values for the supplied family definitions. LLM-assisted exploration is restricted to proposing candidate recurrences, transfer structures or closed forms. For the calculations reported here, OpenAI's GPT-5.6 Sol was used for this candidate-generation stage. A selected proposal is then converted to an explicit symbolic expression or operator representation. Only after this form is fixed are the additional evaluations used for testing generated. A proposed pattern is therefore not counted as its own verification.
For the calculations reported here, the retained family constructors, candidate expressions, explicit word lists and evaluations define the discovery, transfer-reconstruction and verification inputs. The mixed-family plan contains 459 words. The pure-braid evaluation set contains 255 distinct short words, including the Hankel input and words of lengths up to nine, together with 20 completed extrapolation cases of lengths 101, 125, 150 and 200.
The computational record keeps
conjecture generation
symbolic construction
additional tests separate. In particular, the words used to construct the Hankel realization are not relabeled as holdouts; the length-101, 125, 150 and 200 cases probe extrapolation beyond the short-word reconstruction data. We next retain the proposed structures and work through their algebraic consequences.
Supplementary Note 7.B | Commuting transfer laws for homogeneous and mixed theta-derived families
The three homogeneous laws in Fig. 4d, Fig. 4g and Fig. 4j, together with the mixed law in Fig. 4k, share the same reconstructed three-channel representation. We use the factors , , , and defined in Eq. (9), abbreviating them as , , , , when no ambiguity is possible. The common boundary vectors are
The three local cell types are denoted , , , with reconstructed transfer matrices
Eqs. (S31) and (S32) specify the proposed local transfers and boundary vectors. Their products give the expressions below by exact algebra. The normalized homogeneous and mixed formulas in this subsection concern nonempty constructions, .
Cross-linked family . Fig. 4b and Fig. 4c show the cross-linked family at and , respectively, and Fig. 4d displays the general-m construction and closed form. A member with parameter contains identical cells; its candidate expression is
(S33)
The three terms of the closed form are the three transfer channels propagated through m repeated cells.
Lower-paired family . Fig. 4e and Fig. 4f show the lower-paired family at and , and Fig. 4g displays its general-m law. For this family,
(S34)
The alternating sign therefore arises entirely from the third eigenvalue of the lower-paired cell.
Two-sided family . Fig. 4h and Fig. 4i show the two-sided paired family at and , and Fig. 4j displays its general-m law. For this family,
(S35)
These formulas arose from LLM-assisted exploration of data generated by KnottedGraph. Their common three-dimensional transfer description uses different diagonal operators for the three local motifs. The algebraic expansions above make their shared structure explicit.
The zero-motif boundary needs separate normalization. At , the unshifted matrix contraction is . Its minimum degree is two, so Eq. (7) gives ; the unshifted expression is not the normalized result. A zero-motif construction is not automatically the empty graph.
Mixed family with commuting transfer operators . The mixed construction and its count-only family law are shown in Fig. 4k. This family formula provides an expression for an arbitrary mixture of the motifs , , . Using the ordered motif word and count vector defined in Eq. (10), let denote the knotted graph generated by that word. The reconstructed transfer law and its commuting reduction are

Supplementary Fig. 10 | A worked ordered braid word outside the reconstruction basis. The same 8-vertex, 12-edge abstract multigraph used for the order-sensitive family is decorated here by , with and read from left to right. Each block is a pure three-braid, so the three strands return to the same endpoints. The word changes the spatial embedding in the highlighted three-strand region while preserving the surrounding cubic graph. The corresponding transfer product is . Although this word is outside the coordinate basis, it occurs in the input block as and is not an independent holdout.
Since the proposed transfer matrices commute, their products depend only on the motif counts. The resulting three transfer channels contribute
(S37)
Their sum gives the candidate mixed-family invariant:
(S38)
Under this transfer identification, if two words and have the same motif-count vector, . This is the count-only reduction summarized in Eq. (11). Direct evaluation agrees with this predicted formula on all 459 words in the completed mixed-family plan. The expression in Fig. 4k is invariant under motif reordering by construction. The finite comparisons support its proposed identification with the graph family.
Supplementary Note 7.C | Noncommuting transfer operators retain braid-word order
The fixed-graph pure-braid family in Fig. 41 provides the order-sensitive motif family. Its reconstructed transfer operators satisfy the noncommutativity condition in Eq. (13), so we treat it as an order-sensitive family with a noncommuting transfer representation. The underlying 8-vertex, 12-edge cubic multigraph is fixed, and three distinguished edges carry an ordered word in the standard Artin braid generators [41],
The geometry is shown for in Supplementary Fig. 10. Here exchanges strands 1 and 2; exchanges strands 2 and 3 [41]. Squaring either generator restores the endpoint permutation, so changing the word changes the embedding of the braid region while preserving the abstract cubic graph. The first order-sensitive example already occurs at length three. The words AAB, ABA and BAA all have , yet the relation in Eq. (12) shows that the invariant retains information beyond motif counts.
A 15-dimensional Hankel realization. We encode the word dependence directly from Yamada-polynomial data. Choose the 15 word indices
For left and right words , define
Each entry is the Yamada polynomial obtained by concatenating the row word and column word. For example,
and the second entry corresponds to the graph in Supplementary Fig. 10.
The symbolic block in Eq. (S41) is nonsingular over . A nonzero exact determinant evaluation at witnesses that its determinant is not the zero rational function. Thus the finite block has rank fifteen:
This rank is consistent with the fifteen-element generating set for the three-strand Yamada module described by Ref. [49]. To use it as a global upper bound for this graph family, its local braid action and external closure must be shown to factor through that space. Finite-rank realization theory then supplies the connection to a minimal linear representation [47, 48].
Reconstructing the A and B actions. To determine how one additional braid block acts, define two shifted matrices using the same row and column words:
For example,
H joins the two words directly; and insert one additional A or B between them. All entries are obtained from KnottedGraph; the longest word required here has length nine. Following the finite-rank realization construction [47, 48], the transfer matrices are the unique operators satisfying
They encode the effect of adding an A or B block. Let R select the empty-word state and let be the empty-word row of H. With these boundary vectors, the proposed raw-word representation is
For the worked word AAABA, the matrices act from right to left:
The first four nonempty words in this path, A, BA, ABA, AABA, belong to B. The final word AAABA does not. The last application of therefore leaves the set of coordinate basis words and produces the 15-state vector representing the continuation behavior of AAABA. The final contraction with gives its Yamada polynomial.
Three channels for repeated blocks. The reconstructed matrices satisfy the common cubic identity already stated in Eq. (14). Thus powers of either or contain only three spectral contributions. Define
With these projectors, the repeated-block power law is the relation already given in Eq. (15). Hence a repeated run uses the same three fixed projectors; only the scalar powers depend on the run length. These expressions are identities over . At special values where the displayed eigenvalues coincide, the projector fractions require a limit or a direct matrix calculation before specialization.
Arbitrary ordered words. Write the word as maximal runs,
For example,
Substituting Eq. (15) into Eq. (S46) gives
The run lengths enter through scalar powers, while the sequence of A- and B-projectors remains ordered. This retained matrix order is what allows the invariant to distinguish same-count words.
For a nonzero raw polynomial, the normalized invariant is obtained from the general normalization rule in Eq. (7), with .
Worked prediction outside the reconstruction basis. The graph in Supplementary Fig. 10 has
which is not one of the 15 coordinate words in B. Substituting the run lengths into Eq. (S50) gives
(S51)
The first four transfer steps remain on coordinate states in :
The final multiplication produces the state associated with the out-of-basis word AAABA as a linear combination of the 15 reconstruction states. Expanding Eq. (14) gives
Substitution into Eq. (S51) yields
(S53)
The three remaining contractions correspond to words already contained in :
(S54)
The polynomial of the out-of-basis word is obtained from three basis-word polynomials:
(S55)
This example shows explicitly how the finite transfer representation evaluates a word that is not itself one of the 15 coordinate states. Its value is already present in the Hankel input as . The length-101, 125, 150 and 200 comparisons below probe the stronger extrapolation regime in which the evaluated words are also absent from all short-word data used to construct and .
The matrices use only words of length at most nine. Exact checks verify the finite-block rank, , , a nonzero commutator and the cubic identities for both matrices. Direct evaluation agrees with the transfer expression on 255 distinct short words. Twenty additional comparisons have lengths 101, 125, 150 and 200 and agree coefficient-by-coefficient in both raw and normalized form.
Supplementary Note 8 | Software architecture and reproducibility
Supplementary Fig. 11 shows how the source package is organized. Each box is a group of functions, and each arrow shows which object is passed from one group to the next. Data enter at the upper left, are converted to a knotted graph along the top row, and are stored in the Embedded Graph Core at the centre of the figure. From this core object, the workflow branches to projection and Yamada evaluation on the left, geometric relaxation on the right, and visualization and scientific applications along the bottom. The package modules follow the same division into knotted_graph.inputs, knotted_graph.extraction, knotted_graph.core, knotted_graph.layout, knotted_graph.projection, knotted_graph.invariants, knotted_graph.visualization and knotted_graph.applications. The modules are divided by the type of object they receive and return, not by scientific application, so the same code serves every example in this work. The boxes are described below in the order in which data pass through them.
Entry points: USER API and Graph & Scientific Models. A calculation can start in two ways. Through the USER API box, the user supplies their own data: a structure file, a coordinate array, a node–edge table or a surface mesh. Through the Graph & Scientific Models box, the user instead asks the package to generate an input from a definition, such as a named knot or link, a braid word, a mathematical spatial graph or a Hamiltonian model (Supplementary Table 1). Both routes lead to the Input Adapters.
Input Adapters. The Input Adapters (knotted_graph.inputs) read each input and apply the checks and conversions listed in Supplementary Table 1. Examples include selecting a protein chain, ordering polymer atoms and checking node coordinates. Where the output goes depends on what the input already contains. Inputs that already describe a curve or graph are passed directly to the Embedded Graph Core (downward arrow). These include backbones, polymer chains, coordinate curves and node–edge networks. Surfaces, volumes and fields do not yet contain a graph, so they are sent to Skeletonization & Extraction (rightward arrow).
Skeletonization & Extraction. This box (knotted_graph.extraction) receives a surface or volume and returns a first, uncleaned knotted graph. It fills the surface to a voxel volume and thins this volume to a one-voxel-wide skeleton. It then converts the skeleton to graph vertices and edges using the multiscale junction selection of Supplementary Note 1.C (Supplementary Fig. 2a–d). For large skeletons, a compiled C++ implementation performs this step. It applies the same shortcut-removal and graph-selection rules as the Python implementation, so it changes the running time but not the selected graph.

Supplementary Fig. 11 | Modular organization of KnottedGraph. Each box is a group of package functions, and each arrow shows the object passed from one box to the next. Data enter at the upper left, either as user-supplied data (USER API) or as generated models (Graph & Scientific Models), and are read by the Input Adapters. Inputs that already describe a curve or graph go directly to the Embedded Graph Core. Surfaces, volumes and fields first pass through Skeletonization & Extraction and then Embedded Graph Construction & Cleanup. The resulting knotted graph in the core can be relaxed geometrically (Repulsive Layout). It can also be projected and encoded as a PD code (Projection & PD Encoding) for Yamada Evaluation, drawn (Visualizations) and used in larger workflows (Scientific Applications). Users whose data already match the input of a later box can start at that box.
Embedded Graph Construction & Cleanup. The raw graph can still contain artifacts of voxelization. Typical artifacts are short spurious branches, single junctions split into several nearby vertices, and jagged edges. This box removes them with the operations shown in Supplementary Fig. 2e–h: leaf removal, degree-two chain collapse, short-edge contraction and polyline smoothing. Leaf removal and short-edge contraction are applied only when suitable for the target object, because they can delete real features, such as the terminal branches of a biological tree. The cleaned graph is stored in the Embedded Graph Core, or it can be passed directly to Repulsive Layout. The two opposite arrows between this box and the core indicate that the same cleanup operations can also be applied to a graph already stored in the core.
Embedded Graph Core. The core (knotted_graph.core) holds the central object of the package: a knotted graph compatible with networkx.MultiGraph [64]. Each vertex stores its three-dimensional position in the attribute pos. Each edge stores its ordered three-dimensional polyline in pts, and the two ends of this polyline coincide with the positions of the edge's end vertices. Parallel edges and self-loops are kept as separate edges, so closed curves and multigraphs are represented without loss. The downstream projection, layout, visualization and application boxes can use this same graph. A graph built from any input can therefore be projected, relaxed, drawn or analysed without further input conversion; Yamada Evaluation receives the PD representation produced by projection.
Repulsive Layout. This optional box (knotted_graph.layout) changes only the coordinates of a graph, not its connectivity. It is useful when an embedding is valid but hard to project, for example when separate edges pass very close to each other. It relaxes the curves by tangent-point-energy repulsion (Supplementary Note 6). Graph vertices are kept fixed by default, and each coordinate update can be checked to confirm that no edge passes through another. The relaxed coordinates are written back to the same graph. That graph returns to the core (leftward arrow) and continues to projection like any other input.
Projection & PD Encoding. This box (knotted_graph.projection) converts the three-dimensional graph into a planar diagram, the form required by the Yamada calculation (Supplementary Note 2). It samples viewing directions and rejects views in which a crossing cannot be resolved reliably. It records which edge passes over at each crossing and writes the diagram as a PD code (Supplementary Fig. 3). The crossings and their positions along both edges are found in a single geometric search, so they do not have to be located again when the PD code is written. The output is a ProjectionResult object, which stores the selected view together with its diagram and PD code. This object is passed to Yamada Evaluation and can also be drawn by Visualizations.
Yamada Evaluation. This box (knotted_graph.invariants) receives a PD code and computes the exact Yamada polynomial, optionally in normalized form (Supplementary Note 3). A user who already has a diagram or PD code can start here directly, without any three-dimensional geometry (Supplementary Table 1). Coefficients are first computed with 64-bit integers. If any coefficient exceeds that range, the calculation is automatically repeated with arbitrary-size integers, so the result remains exact. The output is a YamadaComputationResult, which stores the polynomial together with the projection it was computed from. Each value can therefore be traced back to its diagram. Reproducing the value from the original data also requires the source data, the conversion choices and the software revision (see below).
Visualizations and Scientific Applications. The two boxes at the bottom right use the objects produced above rather than creating new representations. The Visualizations box (knotted_graph.visualization) draws graphs from the core, diagrams from projection and results from applications. Scientific Applications (knotted_graph.applications) contains the workflows used in this work: material-surface utilities (materials.py); mathematical examples (mathematical.py); knot-deformation workflows (knot_deformation.py); nodal models (nodal/); and parameter sweeps (phase_maps.py). These modules prepare scientific inputs and then call the same extraction, projection and invariant functions described above. For example, the Hamiltonian scans in Supplementary Note 5 and the family calculations in Supplementary Note 7 use the same graph-construction and Yamada code. Application code is kept outside the core, so adding a new application does not change the topology implementation. The phase_map_examples package provides three commands. inspect and plot read and display saved scan records, whereas scan runs a new scan. Its quick scan profile is a small demonstration only; its output is not a convergence study and does not replace the research calculations reported here.
Installation and dependencies. The base installation contains only what is needed to build a knotted graph, project it and evaluate its invariants. This includes NumPy for numerical arrays [86], SymPy for symbolic expressions [87], and the required graph-processing and projection libraries. Workflow-specific functionality is available as optional extras: knot-fields, nodal, surface, viz, repulsion, notebook and benchmark. For example, a user who only needs graph or PD-code input and Yamada evaluation does not have to install the surface-processing, interactive-visualization or benchmark packages. Development, testing and documentation dependencies are kept separate from the runtime package. The native Repulsor solver used by Repulsive Layout is not built by installing the Python repulsion extra. It requires its own source setup and compilation, which are described in the repulsive-layout documentation.
The package requires Python 3.11 or later. Installation and usage are documented in the repository README and in the doc/ directory. This directory contains a quick-start guide, application tutorials, API reference and developer documentation. Example scripts and notebooks are included in the source repository but are not part of the installed Python package. Likewise, an installed wheel should not be assumed to include research-reference CSV files, geometry bundles or large interactive HTML results; the phase-map tools can instead read records supplied by the user. Reproducing the final input figures additionally requires the figure-composition (compositor) source code and its accepted bundle of external panels.
Reproducibility. Reproducibility follows the same module boundaries. Unit and regression tests check the reusable package interfaces. The application notebooks in User_guide/applications write their outputs in machine-readable form. The repository listed under Code and data availability provides the public interfaces and a uv.lock file that records the exact dependency versions. The package alone does not reproduce a specific calculation. Each calculation also needs its input data, preprocessing choices, parameters, implementation choices and verification records. For example, the finite mathematical checks in Supplementary Note 7 retain their constructors, matrices and explicit word lists. The software configuration of a calculation is fixed by three records: the source revision, the lockfile and the parameter record. Hardware and implementation details are stored with the corresponding benchmark records.