Table of Contents
Fetching ...

Colorful Talks with Graphs: Human-Interpretable Graph Encodings for Large Language Models

Angelo Zangari, Peyman Baghershahi, Sourav Medya

TL;DR

The paper tackles the mismatch between graph-structured reasoning and text-based LLMs by introducing CL-OWL, a graph-to-text encoding that maps Weisfeiler–Lehman structural refinement into human-interpretable color tokens within prompts. It provides a principled construction of node-level descriptors via ordered 1-WL, establishes a centrality-like interpretation, and demonstrates that color-based, structure-preserving prompts improve LLM performance on global graph tasks and long-range dependencies across synthetic and real datasets. Theoretical results link ordered WL labels to distance-weighted connectivity, and extensive experiments show that color-enhanced prompts (CL-OWL) outperform baselines on maximum flow, shortest path, and related tasks, with exceptions like triangle counting where local pattern matching dominates. Overall, the approach enhances LLM-based graph reasoning by aligning graph structure with linguistic priors, enabling scalable, interpretable, and effective reasoning over graph data.

Abstract

Graph problems are fundamentally challenging for large language models (LLMs). While LLMs excel at processing unstructured text, graph tasks require reasoning over explicit structure, permutation invariance, and computationally complex relationships, creating a mismatch with the representations of text-based models. Our work investigates how LLMs can be effectively applied to graph problems despite these barriers. We introduce a human-interpretable structural encoding strategy for graph-to-text translation that injects graph structure directly into natural language prompts. Our method involves computing a variant of Weisfeiler-Lehman (WL) similarity classes and maps them to human-like color tokens rather than numeric labels. The key insight is that semantically meaningful and human-interpretable cues may be more effectively processed by LLMs than opaque symbolic encoding. Experimental results on multiple algorithmic and predictive graph tasks show the considerable improvements by our method on both synthetic and real-world datasets. By capturing both local and global-range dependencies, our method enhances LLM performance especially on graph tasks that require reasoning over global graph structure.

Colorful Talks with Graphs: Human-Interpretable Graph Encodings for Large Language Models

TL;DR

The paper tackles the mismatch between graph-structured reasoning and text-based LLMs by introducing CL-OWL, a graph-to-text encoding that maps Weisfeiler–Lehman structural refinement into human-interpretable color tokens within prompts. It provides a principled construction of node-level descriptors via ordered 1-WL, establishes a centrality-like interpretation, and demonstrates that color-based, structure-preserving prompts improve LLM performance on global graph tasks and long-range dependencies across synthetic and real datasets. Theoretical results link ordered WL labels to distance-weighted connectivity, and extensive experiments show that color-enhanced prompts (CL-OWL) outperform baselines on maximum flow, shortest path, and related tasks, with exceptions like triangle counting where local pattern matching dominates. Overall, the approach enhances LLM-based graph reasoning by aligning graph structure with linguistic priors, enabling scalable, interpretable, and effective reasoning over graph data.

Abstract

Graph problems are fundamentally challenging for large language models (LLMs). While LLMs excel at processing unstructured text, graph tasks require reasoning over explicit structure, permutation invariance, and computationally complex relationships, creating a mismatch with the representations of text-based models. Our work investigates how LLMs can be effectively applied to graph problems despite these barriers. We introduce a human-interpretable structural encoding strategy for graph-to-text translation that injects graph structure directly into natural language prompts. Our method involves computing a variant of Weisfeiler-Lehman (WL) similarity classes and maps them to human-like color tokens rather than numeric labels. The key insight is that semantically meaningful and human-interpretable cues may be more effectively processed by LLMs than opaque symbolic encoding. Experimental results on multiple algorithmic and predictive graph tasks show the considerable improvements by our method on both synthetic and real-world datasets. By capturing both local and global-range dependencies, our method enhances LLM performance especially on graph tasks that require reasoning over global graph structure.
Paper Structure (33 sections, 1 theorem, 4 equations, 5 figures, 10 tables, 2 algorithms)

This paper contains 33 sections, 1 theorem, 4 equations, 5 figures, 10 tables, 2 algorithms.

Key Result

Theorem 1

Let $\ell^{(t)}$ be the labels produced by ordered 1-WL on $G$. (1) Degree consistency. For any nodes $v,w\in V$, $\deg(v)>\deg(w) \;\Longrightarrow\; \ell_v^{(1)} > \ell_w^{(1)}$. (2) Shell-dominance implies label dominance. Fix $T\ge 1$. Suppose there exist nodes $v,w\in V$ such that (i)$|S_k(v)|

Figures (5)

  • Figure 1: Overview of the proposed Colorful Ordered Weisfeiler–Lehman (CL-OWL) pipeline. A graph is first represented as nodes with adjacency lists, then processed using ordered 1-WL refinement to compute node-level structural labels. These labels are mapped to human-tangible color tokens and embedded into a natural-language prompt. The resulting prompt enables an LLM to perform graph reasoning tasks (e.g., maximum-flow).
  • Figure 2: Iterative refinement of WL labels and their mapping to human-interpretable colors, showing how structural equivalence classes evolve as increasingly larger neighborhoods are incorporated.
  • Figure 3: Prompt template for max-flow using the CL-OWL method
  • Figure 4: Prompt template for cycle check using L-OWL
  • Figure 5: Prompt template for shortest path using C-OWL

Theorems & Definitions (3)

  • Definition 1: Distance-shell counts and truncated connectivity
  • Theorem 1
  • proof : Proof sketch