Graph Reasoning Linearization
- Graph Reasoning Linearization is a process that maps non-sequential graph structures into ordered token sequences, enabling effective reasoning by neural models.
- It supports applications such as AMR parsing, graph-to-text generation, and fact verification through strategies like depth-first, reverse, and centrality-based traversals.
- Empirical findings show that tailored linearization orders and dual encoder methods mitigate structure loss, enhancing token prediction accuracy and overall model performance.
Graph Reasoning Linearization is the process of mapping a graph—a fundamentally non-sequential, relational structure—into a linear token sequence, so that sequence-to-sequence neural models and LLMs, which operate natively over text, can process, analyze, and reason about graph-structured data. This technique underpins a wide range of modern approaches to Abstract Meaning Representation (AMR) parsing, graph-to-text generation, graph-based question answering, logical inference over graphs, and programmatic graph reasoning in LLMs. The design of linearization strategies, their associated orderings, and the management of information loss or bias introduced by these transformations are core topics in the field.
1. Formal Definitions and Linearization Orderings
Let be a graph, with the set of nodes (often labeled concepts or entities) and a set of edges (possibly labeled, directed, or attributed). A graph linearization is a bijective mapping of to a sequence , such that can be recovered unambiguously from via a deterministic de-linearization process (Gao et al., 2023). More generally, for any concrete task (AMR parsing, knowledge graph prompt construction, etc.), the linearization mapping may take the form
where is the class of graph objects and the set of token sequences.
Crucially, the order in which graph components are linearized can encode different inductive biases or affect the difficulty of the downstream reasoning task. For instance:
- In AMR parsing, default (L2R) linearization uses a left-to-right depth-first traversal (PENMAN order), while reverse (R2L) linearization traverses nodes in the symmetric right-to-left order (Gao et al., 2023).
- For knowledge graphs constructed from text, a flat triple list—e.g., sequences—serves as the linearization underlying LLM-augmented reasoning (Han et al., 14 Jan 2025).
- Linearization orderings can be determined by centrality (degree, PageRank), degeneracy (-core), or be randomized for invariance or adversarial robustness (Xypolopoulos et al., 25 Oct 2024, Hoyle et al., 2020).
Reverse or alternative orderings are also introduced to mitigate position-dependent degradation, as discussed in Section 2.
2. Structure-Loss Accumulation and Positional Bias
Auto-regressive sequence models for graphs (e.g., seq2seq AMR parsers) iteratively decode the output sequence, predicting token conditioned on prior tokens . Empirical analysis reveals that node and edge F1 accuracies are strongly negatively correlated with decoding position: later-decoded tokens suffer from higher error rates due to error propagation and vanishing context (Gao et al., 2023). Specifically, in AMR parsing, Pearson's (F1, ) for nodes is about and for edges about .
This phenomenon, termed structure loss accumulation, poses a general challenge to graph-to-sequence models, especially when most of the graph's structural information is mapped to the end of the sequence. Reverse linearization can be used to surface such structures earlier, providing more uniform prediction performance across positions.
3. Linearization Techniques and Algorithmic Realizations
Canonical and Reverse Traversals
Common methods include canonical depth-first search (PENMAN), reconfigured traversals (re-rooting, flipping edges), random spanning tree orderings, and hybrid schemes. In the Reverse Graph Linearization (RGL) method for AMR parsing (Gao et al., 2023), two linearization orders are defined:
- : DFS-L2R, emitting the graph in penman order.
- : DFS-R2L, reversed child processing at each node.
This duality enables two-pass training (described below) and more robust representation.
Centrality and Degeneracy
LLM-oriented graph reasoning benefits from linearizations that maximize local dependency (neighboring tokens in the sequence reflect local neighborhoods in the graph) and global alignment (starting the sequence at a globally recognized anchor node), facilitating model regularity and effective context utilization under the transformer architecture (Xypolopoulos et al., 25 Oct 2024). Centrality-based orderings (degree, PageRank, closeness) and degeneracy orderings (-core peeling) each provide systematic methodologies for node sequencing prior to edge enumeration. Node relabeling further assists in normalizing alignment across different graphs.
Pseudocode for Centrality-Based Linearization
1 2 3 4 5 6 7 8 9 |
def centrality_linearization(G, centrality_fn): centrality_scores = {v: centrality_fn(G, v) for v in G.nodes} nodes_sorted = sorted(G.nodes, key=lambda v: -centrality_scores[v]) edge_sequence = [] for v in nodes_sorted: for u in G.neighbors(v): if (v, u) not in edge_sequence and (u, v) not in edge_sequence: edge_sequence.append((v, u)) return edge_sequence |
Graph-to-Text Prompt Construction
For LLM-enabled graph reasoning (RwG, Graph-R1, GraphText), linearization typically outputs a flat, human- or machine-readable list of entities and relations, often in triple format. XML-style tags, candidate delimiters, or natural language rendering further structure the output for prompt engineering (Han et al., 14 Jan 2025, Zhao et al., 2023, Wu et al., 24 Aug 2025).
4. Mitigating Linearization-Induced Deficits: Dual Encoders, Self-Distillation, and Invariance
RGL (Gao et al., 2023) introduces dual-encoder architectures and reverse-order self-distillation to counteract accumulation-induced degradation. The training regime uses both gold-standard reverse orderings and "silver" (inferred) reverse orderings in a teacher–student framework, optimizing a compound loss with scheduled balancing between cross-entropy and KL divergence. The forward pass incorporates a sentence encoder, a graph encoder on the reverse linearization, and a gated cross-attention decoder.
Empirical studies (Hoyle et al., 2020) show that training on multiple linearizations (canonical, random, adversarial) can reduce overfitting to a fixed order and promote invariance, which is critical for robust generalization across varied graph topologies.
5. Applications: Parsing, Reasoning, Generation, and Verification
Graph reasoning linearization underpins multiple practical domains:
- AMR Parsing: State-of-the-art parsers employ linearization-based seq2seq models, with reverse orderings and self-distillation yielding increases of +0.8 (AMR 2.0) and +0.5 (AMR 3.0) Smatch scores relative to prior SOTA (Gao et al., 2023).
- LLM-Based Reasoning: Graph-to-sequence templates with explicit linearized triples, often in iterative verification/generation loops, significantly boost logical and multi-hop QA performance over CoT and baseline LLM prompting (+10 points or more in multi-iteration AR-LSAT tasks) (Han et al., 14 Jan 2025).
- Graph-to-Text Generation: Linearization-aware denoising objectives, particularly under low-resource settings, yield substantial BLEU improvements (+5) for AMR generation tasks (Hoyle et al., 2020).
- Interpretable Fact Verification: Context-aware linearization of tabular or list-based evidence enables graph attention models to outperform standard evidence retrieval and classification pipelines, also furnishing explicit rationales via attention weights (Kotonya et al., 2021).
- Executable Code Generation: For arithmetic graph tasks, encoding the graph as executable code blocks allows LLMs to reach near-perfect accuracy (>97%) across tasks and graph encodings, in contrast to the inconsistent performance of pure-text linearizations (Cai et al., 25 Aug 2024).
6. Theoretical Foundations and Extensions: Linearity, Contiguity, and Logic
Graph linearization relates to classical concepts of graph encoding and representation:
- Linearity-k and Contiguity-k: A closed linearity-k encoding uses linear orders and one interval per vertex per order to reconstruct vertex neighborhoods (Crespelle et al., 2018). Linearity is strictly more powerful than contiguity; for certain cographs, the linearity parameter grows as versus for contiguity. Algorithmic implications include more compact adjacency-listing and faster query routines.
- LexCycle: The parameter LexCycle(G) measures, through LexBFS multisweeps, how far a graph is from "perfectly linearizable" structure. For cographs, interval, proper interval, and cobipartite graphs, LexCycle(G)=2; in general, it can be unbounded, with construction techniques yielding arbitrarily large cycles (Charbit et al., 2017).
- Graph–Logic Correspondence: Certain classes of logical graphs map bijectively (up to isomorphism) onto linear logic formulas in the MILL fragment, with linearization interpreted as formula construction and proof-search providing graph-theoretic reasoning (Dixon, 2022).
7. Limitations and Future Directions
- Loss of Structure and Scaling: Flat, sequential linearizations induce tokenization bottlenecks in large graphs, can obscure community structure, and present context length challenges for LLMs (Wu et al., 24 Aug 2025).
- Encoding Choices: The selection of traversal strategy, alignment anchors, or graph-to-sequence rendering can dramatically affect model behavior; no universal method dominates across all tasks, and randomized or adversarial permutations must be used judiciously (Hoyle et al., 2020, Xypolopoulos et al., 25 Oct 2024).
- Human-in-the-Loop and Interactivity: Recent prompts and interactive workflows enable iterative correction, explanation, and calibration of LLMs' graph reasoning, exploiting natural language for both the linearization and the meta-reasoning layers (Zhao et al., 2023).
- Generalizability: RGL-style approaches (dual linearization, self-distillation) and programmatic graph encodings (CodeGraph) have not yet been fully extended to highly structured, large-scale real-world graphs, nor to attributed, dynamic, or multi-relational scenarios.
Graph Reasoning Linearization remains an area of active innovation, with ongoing research developing tools and principles for optimizing both the expressive power and the computational feasibility of sequence-based graph reasoning across the methodological spectrum from pure neural decoding to logic-enriched and program-mediated architectures.
Sponsored by Paperpile, the PDF & BibTeX manager trusted by top AI labs.
Get 30 days free