---
title: Reversible Graph Serialization
url: https://www.emergentmind.com/topics/reversible-graph-serialization
type: topic
---

# Reversible Graph Serialization

Reversible graph serialization denotes a family of representations in which a graph, or a graph-derived object, is mapped into another form together with a recovery guarantee. In the literature, that guarantee is not uniform. Some works define reversibility as exact reconstruction of a discrete graph up to isomorphism from a sequence or string; others target lossless recovery of an RDF graph, a property graph, or a distributed sparse network state; still others use “reversible” for exact bijections over continuous node embeddings, or for logical encodings into auxiliary sparse graphs from which the original graph is first-order interpretable [2603.11039][2603.11099][2506.11298][2601.14906][1905.13177]. The topic therefore spans exact symbolic serialization, stateful binary interchange, graph-to-graph encodings, and more qualified latent or operational notions of reversibility.

## 1. Scope of the term and dimensions of reversibility

A precise discussion of reversible graph serialization depends on three questions: what object is being serialized, what equivalence notion is preserved, and where the inverse depends on auxiliary state. For labeled graphs, one explicit definition is that a serialization \(f\) is reversible if the original labeled graph \(\mathcal{G}\) can be recovered from its sequence \(S=f(\mathcal{G})\) up to isomorphism; formally, there exists \(\mathcal{G}' \in f^{-1}(f(\mathcal{G}))\) such that \(\mathcal{G}' \cong \mathcal{G}\) [2603.11099]. For RDF, the relevant object is not source text but the RDF abstract syntax of triples, quads, graphs, datasets, and streams; reversibility is therefore model-level and not byte-for-byte textual recovery [2506.11298]. For graph normalizing flows, the exact bijection is over \(H \in \mathbb{R}^{N\times d}\) or over continuous node embeddings \(X\), not over discrete adjacency itself [1905.13177].

This yields several distinct regimes.

| Approach | Serialized object | Recovery claim |
|---|---|---|
| IsalGraph [2603.11039] | Finite, simple graph topology | Total decoder on \(\Sigma^*\); connected-graph encoder reconstructs up to isomorphism |
| Frequency-guided graph tokenization [2603.11099] | Labeled graph as an alternating node-edge-node sequence | Exact recovery up to isomorphism; BPE is reversed before \(f^{-1}\) |
| Jelly [2506.11298] | RDF triples, quads, graphs, datasets, and streams | Lossless at the RDF abstract syntax level; not source-text preserving |
| PG / JSON-PG [1907.03936] | Abstract property graph model | Intended round-trip under the model, with caveats on ordering and edge IDs |
| dCSR [2304.05587] | Distributed sparse SNN graph plus aligned state and events | Exact restart if row order, edge order, schema, and auxiliary files are preserved |
| Graph normalizing flows [1905.13177] | Continuous node features or node embeddings | Exact invertibility only for the continuous transform, not for adjacency |

A plausible implication is that “reversible” should not be treated as a single binary label. The strongest form is a total decoder and a graph-level inverse up to a clearly stated equivalence relation. Weaker forms include stateful reversibility, latent-space reversibility, or approximate reversal of a transformation history.

## 2. Exact sequence-based encodings of graph structure

The clearest examples of exact sequential graph serialization are instruction-based strings for simple graphs and edge-covering sequences for labeled graphs.

IsalGraph represents the structure of any finite, simple graph as a string over the nine-character alphabet
\[
\Sigma = \{N,\, n,\, P,\, p,\, V,\, v,\, C,\, c,\, W\}.
\]
Its decoder \(S2G\) is total and deterministic: every string over \(\Sigma\) decodes to a valid finite simple graph, because the virtual machine state \(\mathcal{S}=(G,L,\pi)\) always maintains valid pointers into a circular doubly-linked list whose payloads are graph-node identifiers [2603.11039]. The initial state already contains one graph node, so even the empty string decodes to a one-node graph. The encoder \(G2S(G,v_0)\) is defined for connected graphs and guarantees
\[
S2G(G2S(G,v_0)) \cong G,
\]
with reconstruction up to graph isomorphism rather than preservation of original external node numbering. The string length decomposes into one node-creation instruction per non-root node, one structural instruction per extra edge, and cumulative pointer movement:
\[
|w| \;=\; (N-1) + \bigl(M-(N-1)\bigr) + \sum_k (|a_k|+|b_k|).
\]
A canonical variant is defined by choosing the lexicographically smallest shortest string across all starting nodes and valid traversal orders,
\[
*_G \;=\; \mathrm{lexmin} \Bigl\{\, w \in \mathcal{W}(G) \;\Big|\; |w| = \min_{w' \in \mathcal{W}(G)} |w'| \Bigr\},
\]
but the strongest claim,
\[
G \cong H \;\iff\; *_G = *_H,
\]
is stated as a conjecture rather than a proved theorem [2603.11039].

A second exact sequence paradigm serializes labeled graphs through an edge-covering walk. Here a labeled graph is
\[
\mathcal{G} = (G,L,\Sigma),
\]
with \(L:\mathcal{V}\cup\mathcal{E}\to\Sigma\), and the raw serialization maps
\[
f: \mathcal{G} \mapsto (s_1,\dots,s_k), \qquad s_i\in\Sigma.
\]
The sequence is emitted as an alternating node-edge-node walk,
\[
W = (v_0,e_1,v_1,\dots,e_k,v_k), \qquad
S = (L(v_0), L(e_1), L(v_1), \dots, L(v_k)).
\]
Reversibility is up to isomorphism, with strict node-index identity excluded unless an additional index mapping is supplied [2603.11099]. The default traversal is a Frequency-Guided Eulerian circuit, driven by global frequencies of labeled edge patterns \(p=(l_u,l_e,l_v)\):
\[
\mathrm{Count}(\mathcal{G},p)=\big|\{e=(u,v)\in\mathcal{E}\mid (L(u),L(e),L(v))=p\}\big|,
\]
\[
C(p)=\sum_{\mathcal{G}\in\mathcal{D}} \mathrm{Count}(\mathcal{G},p), \qquad
F(p)=\frac{C(p)}{\sum_{p'\in\Sigma^3} C(p')}.
\]
At a node \(u\), the next edge is selected by
\[
e^* = \arg\max_{e_i \in \mathcal{E}_u} \pi(e_i,F),
\]
with the canonical example \(\pi(e_i,F)=F(p_i)\). For disconnected graphs, components are serialized independently, then sorted primarily by descending length and secondarily lexicographically before concatenation. For undirected graphs, each undirected edge is treated as two opposing directed edges. Byte Pair Encoding is then applied as a reversible symbolic compression layer: merged tokens are expanded by reversing merge rules, after which \(f^{-1}\) reconstructs the labeled graph up to isomorphism [2603.11099].

These two lines differ in scope. IsalGraph targets finite simple graph topology with a total decoder from all strings over a fixed alphabet. Frequency-guided tokenization targets labeled graphs over a finite alphabet and is designed to make frequent local substructures adjacent so that BPE learns useful graph tokens. In both cases, the graph-level representation is discrete and explicit.

## 3. Model-level and systems serializations

A different tradition treats reversible graph serialization as lossless interchange of graph data models or distributed sparse states rather than topology-only string coding.

Jelly is a Protocol-Buffer-based binary serialization for RDF triples, quads, graphs, datasets, and streams. Its stream is divided into frames; it uses three fixed-size string lookup tables for IRI prefixes, IRI suffixes, and datatypes, plus variable-length integer references, delta compression of identifiers, and omission of repeated consecutive terms [2506.11298]. Recovery is stateful: the decoder reconstructs omitted or referenced terms by maintaining synchronized dictionary state and previous-term context. This is lossless at the RDF abstract syntax level, including grouped streams and named graphs, but it is not reversible to exact source text. Prefix declarations, whitespace, comments, line breaks, and source-format-specific surface syntax are not preserved; nor is the byte representation canonical, since table replacement policy and statement order can vary [2506.11298].

For property graphs, the proposed abstract model is
\[
PG = \langle N, E_d, E_u, S, V, P, e, l_n, l_e, p_n, p_e\rangle,
\]
where nodes and edges carry sets of labels and sets of properties, and properties take the form \(p=\langle k,v\rangle\) with \(k\in S\) and \(v\in 2^V\) [1907.03936]. The PG and JSON-PG syntaxes are close to direct encodings of that model and are intended to preserve nodes, edges, directionality, multiple labels, multi-valued properties, and mixed graphs. However, the formal model does not preserve ordering by design, and the serialization lacks edge IDs. As a result, distinguishing parallel edges with identical endpoints, labels, and properties is problematic, and the paper does not explicitly prove injectivity or round-trip equivalence for all model distinctions [1907.03936].

The dCSR proposal extends compressed sparse row storage into a partition-aware serialization for spiking neural networks. The essential claim is that adjacency, vertex state, edge state, model schema, coordinates, partition distribution, and delayed events are all serialized in the same partitioned order as the CSR organization [2304.05587]. The on-disk state is spread across `.adjcy.k`, `.dist`, `.coord.k`, `.state.k`, `.model`, and `.event.k` files. Exact restart requires preserving row order within partitions, partition order, edge order within each row, the `.model` schema, and delayed events; in the directed case, exact reconstruction may also depend on special `none` model identifiers used when the partitioning adjacency is undirected but the simulated synaptic graph is directed [2304.05587]. This is reversible serialization in a strict operational sense: the intended target is checkpoint/restart of the same distributed simulation, not merely an isomorphic graph.

Taken together, these systems show that reversibility can be graph-model-specific and stateful. The inverse may depend not only on bytes but also on lookup-table state, row ordering, partition metadata, or explicit schema.

## 4. Reversible latent and logical encodings

Some influential work uses “reversible” for exact transformations on graph-derived continuous or logical representations, not for direct serialization of discrete adjacency.

Graph normalizing flows define a graph as
\[
\mathcal{G} = (H,\Omega),
\]
where \(H \in \mathbb{R}^{N\times d_n}\) is the node feature matrix and \(\Omega \in \mathbb{R}^{N\times N\times (d_e+1)}\) contains adjacency and optional edge features [1905.13177]. The reversible module partitions node features,
\[
H_t = \operatorname{concat}\!\big(H_t^{(0)}, H_t^{(1)}\big),
\]
and applies RealNVP-style affine coupling with graph-conditioned functions \(F_1,F_2,G_1,G_2\). Earlier hidden states can be reconstructed exactly from later ones, which yields reduced memory usage during backpropagation. In the generative setting, however, the exact bijection is only between continuous node-embedding sets and Gaussian latent codes. Graph generation proceeds as
\[
Z \sim \mathcal{N}(0,I), \qquad X = f^{-1}(Z), \qquad \hat A = \text{decoder}(X),
\]
followed by thresholding. The paper is therefore highly relevant to reversible neural transformations on graph-structured data, but it is only partially relevant to strict reversible graph serialization of discrete graphs, because the encoder and decoder around the flow are not invertible by construction and information loss can occur in reconstruction and thresholding [1905.13177].

A more structural form of reversible encoding appears in the approximate reversal of first-order transductions on sparse graph classes. For any graph class \(C\) that is monadically stable and has inherently linear neighborhood complexity, the paper gives an \(O(n^4)\)-time algorithm that transforms \(G\in C\) into a colored graph \(H\) in a bounded-expansion class \(D\) together with a fixed first-order interpretation \(I\) such that
\[
G = I(H).
\]
This is not faithful inversion of an original transduction instance-by-instance; rather, it constructs a new witness \(H\) from which \(G\) is exactly recoverable by a fixed decoder [2601.14906]. A plausible implication is that reversible graph serialization can also be understood as lossless re-expression of a graph into a more structured graph class, with the inverse supplied by logic rather than by a byte-level parser.

## 5. Reversibility as an operational and semantic constraint

A semantic account of serialization as a reversible effect models a serializer as
```haskell
type Serializer X Y = X ↔ Serialized Y
```
with
```haskell
serialize^\dagger : Serialized X ↔ X
```
acting as a partial deserializer [1805.08605]. The framework is that of dagger arrows and inverse arrows, where partiality is explicit: many serialization methods allow many different serialized representations of the same data, so the inverse need only be defined on outputs actually produced by the serializer. The paper does not discuss graphs explicitly, but it provides a precise formal template for non-canonical reversible serialization.

Local graph evolution imposes further constraints. In the framework of causal graph dynamics, a dynamics \((F,R_\bullet)\) is shift-invariant, continuous, and bounded; invertibility means \(F\) is bijective, and reversibility means \((F^{-1},S_\bullet)\) is again a causal graph dynamics [1805.10330]. In the strict model, invertible dynamics are almost vertex-preserving: there exists a bound \(p\) such that if \(|V(X)|>p\), then the antecedent map \(R_X\) is bijective. The paper therefore recovers reversible local node creation and destruction only in three relaxed settings: Anonymous Causal Graph Dynamics, Invisible Matter Causal Graph Dynamics, and Named Causal Graph Dynamics, and proves these settings equivalent in expressive power [1805.10330]. Invisible matter attaches an infinite binary-tree reservoir to each visible vertex; name algebra uses structured terms with rewrite rules such as
\[
(u \wedge v).l \to u, \qquad (u \wedge v).r \to v, \qquad (u.l \wedge u.r)\to u.
\]
This suggests that exact reversible size change requires provenance to be embedded into the representation itself.

A more limited operational perspective appears in work on uniform memory and a particular case of serialization for \(\lambda\beta\eta\), where serialization is useful for comparing results during computation. The visible text does not establish full graph-level invertibility, but it does show that serialization can be treated as an online computational mechanism rather than merely a storage format [1011.4330].

## 6. Misconceptions, boundary cases, and adjacent graph-to-sequence tasks

A common misconception is that any method described as reversible on graph data is a lossless serializer of discrete graphs. The literature does not support that equivalence. Graph normalizing flows are exactly invertible over continuous node states or embeddings, but not over adjacency matrices themselves [1905.13177]. Frequency-guided tokenization reconstructs labeled graphs up to isomorphism, not original node indices [2603.11099]. Jelly is lossless for RDF content but not for original Turtle, TriG, N-Triples, or JSON-LD source text, and it is not canonical [2506.11298]. dCSR is exact only if ordering conventions and all auxiliary files are preserved [2304.05587]. PG and JSON-PG aim at lossless model-level interchange, yet the lack of edge IDs and the use of set semantics limit strict injectivity [1907.03936].

Canonicality is also distinct from reversibility. IsalGraph has a total decoder and an encoder that reconstructs connected simple graphs up to isomorphism, but the strongest canonical-completeness claim remains conjectural [2603.11039]. This suggests that exact decoding does not by itself solve graph isomorphism or produce a unique normal form.

Finally, not every graph-to-sequence method in a reversible-computation domain is reversible graph serialization. BDD2Seq maps a circuit netlist graph to a variable-ordering permutation for BDD-based reversible-circuit synthesis. The “reversible” qualifier belongs to the synthesized circuit model, while the graph-to-sequence map is task-dependent, many-to-one, and not invertible: the output permutation does not reconstruct the original netlist graph [2511.08315]. This provides a useful negative boundary. Sequence generation from graphs may optimize a downstream reversible computation without constituting reversible graph serialization in the strict representational sense.

The literature therefore supports a layered view of reversible graph serialization. At its strongest, it is an exact, explicit inverse between discrete graph structures and serialized codes, usually up to isomorphism. At weaker but still rigorous levels, it may mean model-level round-tripping of graph data, stateful recovery of distributed sparse state, logical reconstruction from an auxiliary sparse witness, or exact reversibility only inside a latent continuous representation. The technical content of a reversibility claim lies in that distinction.

Source: https://www.emergentmind.com/topics/reversible-graph-serialization