---
title: Colored Token Routing
url: https://www.emergentmind.com/topics/colored-token-routing
type: topic
---

# Colored Token Routing

Colored token routing encompasses a family of combinatorial reconfiguration problems in which tokens, each bearing a color label, must be routed or swapped across the vertices of a graph so that the final arrangement matches a prescribed coloring pattern. Tokens of the same color are considered indistinguishable, and only colored configurations, not token identities, matter. Both sequential (one swap per step) and parallel (multiple swaps via edge matchings per step) models are studied. Colored token routing is motivated by problems in sorting networks, quantum circuit compilation, molecule assembly, and onchain token attribution. The underlying computational questions pose rich complexity-theoretic, algorithmic, and parameterized challenges, tied closely to the structure of the graph, color set, and allowable swap constraints.

## 1. Formal Definition and Problem Variants

The fundamental model comprises:

- An undirected graph $G = (V, E)$.
- A set $C$ of token-colors.
- A mapping $\tau_0: V \to C$ (initial token placement).
- A target coloring $\tau^*: V \to C$, with $\forall c \in C$, $|\{v: \tau_0(v) = c\}| = |\{v: \tau^*(v) = c\}|$.

A legal move swaps tokens on adjacent vertices $\{u, v\} \in E$. The goal is to find a minimal-length sequence of such swaps that transforms $\tau_0$ into $\tau^*$ so that for all $v$, the color at $v$ equals $\tau^*(v)$. The decision version asks, for a given budget $k$, whether such a sequence exists of length at most $k$:
\[
\mathrm{TokenSwapping}_{\mathrm{col}}(G, \tau_0, \tau^*, k)\ :\ \text{Is there a sequence of at most $k$ swaps converting $\tau_0$ into $\tau^*$?}
\]
Extensions include subset token swapping (where a token can have multiple valid destinations) and constrained colored token swapping (where swaps are only allowed between specific pairs of colors, described by a swap-constraint graph $H=(C, E_H)$) [1607.07676, 2601.09681, 1803.06816].

Parallel (or matching-based) variants allow, in each round, a set $M \subset E$ of pairwise-disjoint edges (a matching) to carry out all swaps simultaneously. Given initial and target colorings $f, g: V \to \{1, ..., c\}$, the objective is to minimize the number of parallel swap rounds to reach $g$ [1612.02948, 2411.18581].

## 2. Computational Complexity and Parameterized Results

Colored token routing problems exhibit sharp complexity dichotomies depending on the number of colors, the type of allowed swaps, and the structure of the underlying and swap-constraint graphs.

- **NP-completeness**: The problem is NP-complete for $c=3$ even when $G$ is planar, bipartite, and of degree at most 3 [1607.07676, 1803.06816, 1612.02948]. For parallel (matching) swaps, 3-colored routing is NP-complete for $p=2$ steps, and 2-colored routing becomes NP-hard for $p \ge 3$ [1612.02948].
- **PSPACE-completeness**: The constrained variant CCTS is PSPACE-hard for $k=4$ colors when the swap-constraint graph $H$ is a path $P_4$; membership in PSPACE holds via explicit configuration graph simulation [2601.09681].
- **Fixed-Parameter Tractability (FPT) and XP**:
  - If parameterized by $k$ (the number of swaps), colored token swapping is $W[1]$-hard; no $f(k) n^{o(k / \log k)}$-time algorithm exists unless ETH fails [1607.07676].
  - In nowhere-dense graph classes (including all planar and bounded treewidth graphs), CTS (and even the more general subset token swapping) is FPT in $k$ [1607.07676]. 
  - With parameter $k + \Delta$ (maximum degree), the problem admits an FPT algorithm with a kernel size bounded by $2k + 2k^2 \Delta^k$ [1607.07676].
  - For degree-2 graphs (disjoint paths/cycles), $O(n^{c+2})$-time XP algorithms exist parameterized by $c$ [1803.06816].
  - On the complete graph, CTS is FPT parameterized by color count $c$, using a cycle cover reduction to integer linear programming [1803.06816].

## 3. Algorithmic Frontiers and Special Graph Classes

The tractability border for colored token routing is highly sensitive to the structure of $G$ and the allowed color-interaction graph $H$. The landscape, for both sequential and parallel routing, is summarized as follows [1607.07676, 1803.06816, 1612.02948, 2601.09681]:

| Graph Class     | Unconstrained CTS        | With Swap Constraints H        |
|-----------------|-------------------------|-------------------------------|
| Path            | Poly-time (greedy)      | Star H: poly-time; Path H: hard |
| Star            | Poly-time               | Star H: poly-time             |
| Clique          | NP-complete             |                              |
| Tree (c=2)      | Linear-time             | Star H: poly-time             |
| Tree (c≥3)      | Open                    |                               |
| Planar/cubic    | NP-complete (c≥3)       | PSPACE-complete for $k=4$, $H=P_4$ [2601.09681] |
| Complete graph  | FPT in c                |                               |

For $c=2$, the problem is poly-time solvable on general graphs via a minimum-weight perfect matching approach. Paths and stars admit efficient sorting strategies. For parallel routing, the decision problem is tractable for $c=2$, $p\le2$, but hard for $c\ge3$, $p\ge2$ or $c=2$, $p\ge3$ [1612.02948].

Constrained CTS becomes tractable if and only if the swap-constraint graph $H$ is $P_4$-free (i.e., a clique or a star), and is PSPACE-complete otherwise [2601.09681]. In the star case, the problem reduces to canonical pebble motion, leveraging classical results on the 15-puzzle parity criterion.

## 4. Approximation Algorithms and Quantum Circuit Applications

In parallel colored token routing, constant-factor approximation algorithms have been established for structured graphs prevalent in qubit-mapping for quantum hardware, such as grids, cycles, and subdivided stars [2411.18581]:

- On cycles, coloring reduces to selecting cyclic shifts; a greedy odd–even strategy achieves makespan at most twice the lower bound for even cycles ($A(G,C) \le 2\,\mathrm{OPT}$).
- On subdivided stars, a multi-phase methodology yields complexity at most $4\,\mathrm{OPT} + \min\{\mathrm{OPT}, h\} + 1$, where $h$ is the branch count.
- For $h \times n$ grid graphs, a three-phase row/column/row approach ensures $A(G,C,\mathcal{L}) \le 2\,\mathrm{OPT} + 2h$.

These results guarantee that, for quantum circuit routing, swap depth can be kept within a constant factor of an instance-specific lower bound (maximum token–target distance), providing near-optimality in scheduling SWAP gates for indistinguishable qubits [2411.18581].

The stretch factor, defined as the maximal ratio over all instances of the algorithmic makespan to the distance lower bound, is constant for lines (2), linear in $n$ for cycles, and $O(h)$ for grids.

## 5. Color Constraints, Swap Models, and Token Fungibility

The structure and constraints of the color-interaction graph $H$ (which pairs of colors are allowed to swap when their tokens are on endpoints of an edge) create the most significant impact on both decision and optimization complexity.

- If $H$ is a star—one color swappable with all others, no others allowed—CTS reduces to pebble motion, with a complete polynomial-time characterization using generalized transitivity and permutation parity [2601.09681].
- If $H$ induces a path $P_4$, the problem simulates nondeterministic constraint logic—showing universality and PSPACE-completeness [2601.09681].
- When tokens of the same color are entirely fungible and the only constraint is eventual matching of multiset colorings at each vertex, the system underpins practical algorithms for fungible token attribution in distributed ledgers [2311.08639]. In such models, colored balances are maintained per wallet, and "color routing" involves constrained burns, mints, and cross-domain invariants for consistency and traceability, distinct from graph-reconfiguration models.

## 6. Open Problems and Future Directions

Key open questions concern the complexity of colored token swapping on various families for small $c \ge 3$ (e.g., trees), the existence of constant-approximation algorithms for arbitrary graphs in colored routing via parallel swaps, and the parameterized complexity for novel parameter sets (e.g., total tokens moved, number of color classes occupied). Another direction is the systematic study of stretch-factor tightness on graph classes beyond those with known constant-factor strategies [2411.18581], and the exploration of real-world, large-scale colored routing protocols in high-throughput blockchain and distributed ledger contexts [2311.08639].

The theoretical landscape is now sharply characterized: for unconstrained or star-constrained swaps, colored token routing is in P or FPT (with explicit parametrizations). As soon as swap limitations encode a path of length four in the interaction graph, PSPACE-hardness emerges, even on highly restricted base graphs [2601.09681]. This threshold dictates the tractability frontier for both theoretical study and practical algorithm implementation.

Source: https://www.emergentmind.com/topics/colored-token-routing