Quiver Mutation Visualizer

scroll to zoom · drag to pan · drag nodes to reposition
μ₁
μ₂
μ₃
initial
scroll to zoom · drag to pan · drag nodes to reposition
μ₁
μ₂
μ₃
initial
scroll to zoom · drag to pan · drag nodes to reposition
μ₁
μ₂
μ₃
initial

This app was created by Kyler Siegel with heavy AI assistance. There may be errors.

This is an interactive visualizer for quiver mutations and cluster algebras, two closely related structures introduced by Fomin and Zelevinsky in the early 2000s. Cluster algebras arise in diverse areas of mathematics, including representation theory, Teichmüller theory, tropical geometry, and the study of scattering diagrams. The app runs entirely in the browser—everything is implemented from scratch in a single HTML file using JavaScript and the Canvas API.

Quivers & mutation

A quiver is a directed graph, possibly with multiple edges between vertices but no loops (edges from a vertex to itself) and no 2-cycles (a pair of edges going in opposite directions between two vertices). In this visualizer we work with quivers on $n$ vertices, labeled $1, 2, \ldots, n$ (where $n$ ranges from 2 to 6).

A quiver is equivalently described by its exchange matrix $B$, a skew-symmetric integer matrix where $B_{ij}$ records the number of arrows from $i$ to $j$ (positive) or from $j$ to $i$ (negative).

Mutation at vertex $k$ transforms the exchange matrix $B$ into a new matrix $B'$ by the Fomin–Zelevinsky rule:

$$B'_{ij} = \begin{cases} -B_{ij} & \text{if } i = k \text{ or } j = k, \\ B_{ij} + \dfrac{|B_{ik}|\,B_{kj} + B_{ik}\,|B_{kj}|}{2} & \text{otherwise.} \end{cases}$$

Mutation is an involution: mutating twice at the same vertex returns the original quiver. Note also that mutation preserves skew-symmetry.

Mutation graph

The mutation graph shows all quivers reachable from the initial quiver by iterated mutations, up to a chosen depth. Vertices of this graph are quivers (identified by their exchange matrix), and edges correspond to single mutations, colored by which vertex was mutated: $\mu_1$, $\mu_2$, $\mu_3$, etc. Each node displays a miniature picture of the corresponding quiver.

Two quivers occupy the same node if and only if their exchange matrices are identical. Dashed lines at the boundary indicate mutations that would lead to quivers not yet explored at the current depth.

Exchange graph & cluster variables

A cluster is an $n$-tuple of cluster variables $(x_1, \ldots, x_n)$ together with an exchange matrix. The initial cluster simply has formal variables $x_1, \ldots, x_n$.

When we mutate at vertex $k$, the exchange matrix transforms as above, and the cluster variable $x_k$ is replaced by a new variable $x'_k$ defined by the exchange relation:

$$x_k \cdot x'_k = \prod_{B_{ik} > 0} x_i^{B_{ik}} + \prod_{B_{ik} < 0} x_i^{-B_{ik}}$$

The other $n-1$ variables remain unchanged. The exchange graph records all (quiver, cluster) pairs reachable by iterated mutations. Unlike the mutation graph, two nodes are identified only when both the exchange matrix and the cluster variables agree. This means the exchange graph may have more nodes than the mutation graph.

A foundational result in the theory of cluster algebras is the Laurent phenomenon (Fomin–Zelevinsky, 2002): every cluster variable can be expressed as a Laurent polynomial in the initial variables $x_1, \ldots, x_n$—that is, a polynomial with integer coefficients divided by a monomial. This is nontrivial because the exchange relation involves division, and it is not obvious a priori that repeated application always produces Laurent polynomials.

g-vectors & c-vectors

Each seed (exchange matrix + cluster) carries two additional integer matrices: the $G$-matrix (whose columns are the g-vectors) and the $C$-matrix (whose columns are the c-vectors). Both are $n \times n$ integer matrices, initialized as the identity $G = C = I_n$.

g-vectors

The g-vector $\mathbf{g}_i \in \mathbb{Z}^n$ of a cluster variable $x_i$ records its “leading term” in a certain tropical sense. More precisely, $\mathbf{g}_i$ encodes the multi-degree of $x_i$ with respect to the initial cluster when we write the cluster variable as a Laurent polynomial and extract the monomial with the most refined dominance. In the initial seed, $\mathbf{g}_i = \mathbf{e}_i$ (the $i$-th standard basis vector).

When mutating at vertex $k$, the $G$-matrix updates as follows. Let $\varepsilon_k$ denote the sign of the $k$-th c-vector (by sign-coherence, all nonzero entries of $\mathbf{c}_k$ share the same sign). Then the $k$-th column of $G$ is replaced by:

$$\mathbf{g}'_k \;=\; -\mathbf{g}_k \;+\; \sum_{i} [\varepsilon_k \, B_{ik}]_+\;\mathbf{g}_i$$

where $[x]_+ = \max(x, 0)$. All other columns of $G$ remain unchanged.

Fomin and Zelevinsky conjectured (and it was subsequently proved) that the g-vectors of any cluster form a $\mathbb{Z}$-basis of $\mathbb{Z}^n$, and that distinct cluster variables always have distinct g-vectors.

c-vectors

The c-vector $\mathbf{c}_i \in \mathbb{Z}^n$ tracks how the $i$-th coefficient (frozen variable) transforms under mutation. When mutating at vertex $k$, the $C$-matrix updates as follows. The $k$-th column is negated, and each other column $j \neq k$ is adjusted:

$$\mathbf{c}'_k = -\mathbf{c}_k, \qquad \mathbf{c}'_j = \mathbf{c}_j + [-\varepsilon_k \, B_{kj}]_+\;\mathbf{c}_k \quad (j \neq k)$$

where $\varepsilon_k$ is the sign of $\mathbf{c}_k$ as above.

A key property is sign-coherence: every c-vector is either a nonnegative or a nonpositive vector (all entries share the same sign). This was conjectured by Fomin and Zelevinsky and proved in various generality by Derksen–Weyman–Zelevinsky, Gross–Hacking–Keel–Kontsevich, and others.

Tropical duality

The $G$- and $C$-matrices satisfy the tropical duality relation $G^T C = I$ at every seed. In particular, knowing one matrix determines the other. This app computes both independently via the mutation formulas above, which also serves as an internal consistency check.

Scattering graph

The scattering graph is based on a piecewise-linear mutation operation on tuples of integer vectors in $\mathbb{Z}^2$, motivated by the theory of scattering diagrams. Given a tuple of vectors $(\mathbf{v}_1, \ldots, \mathbf{v}_n)$, we define a piecewise-linear shear $\mu_{\mathbf{v}}$ for any vector $\mathbf{v}$ by:

$$\mu_{\mathbf{v}}(\mathbf{w}) = \mathbf{w} + \min(\mathbf{w} \wedge \mathbf{v},\, 0)\,\mathbf{v}$$

where $\mathbf{w} \wedge \mathbf{v} = \det(\mathbf{w}, \mathbf{v})$ is the $2 \times 2$ determinant. Mutation $\operatorname{mut}_k$ negates the $k$-th vector and applies $\mu_{\mathbf{v}_k}$ to the other two. Unlike quiver mutation, these mutations are not involutions, but we still require that mutation sequences have no consecutive repeats.

Each mutated tuple carries not only the current vectors but also the mutation path $i_1, \ldots, i_m$ used to reach it. The base-mapped tuple is obtained by recursively unwinding this path: at each step, the inverse shear $\mu_{\mathbf{v}}^{-1}(\mathbf{w}) = \mathbf{w} - \min(\mathbf{w} \wedge \mathbf{v},\, 0)\,\mathbf{v}$ is applied (with respect to the negated mutated vector $-\mathbf{v}'_{i_m}$) to all $n$ components, peeling off the last mutation.

Two nodes in the scattering graph are identified if they have the same base-mapped tuple. When “Vector tuple” is selected, the initial tuple is taken directly from the user-specified vectors. For other quiver presets, an initial tuple is derived from the exchange matrix $B$ by choosing vectors satisfying $\det(\mathbf{v}_i, \mathbf{v}_j) = B_{ij}$.

Preset quivers
  • Vector tuple — A quiver defined by $n$ user-specified vectors $\mathbf{v}_1, \ldots, \mathbf{v}_n \in \mathbb{Z}^2$ (with $n$ selectable from 2 to 6). The exchange matrix entry $B_{ij}$ is the determinant $\det(\mathbf{v}_i, \mathbf{v}_j)$. The default vectors for $n=3$ are $(1, 0), (0, -1), (-1, -2)$, corresponding to the Hirzebruch surface $F_1$.
  • Markov — A 3-cycle with 2 arrows on each edge, related to the Markov equation $x^2 + y^2 + z^2 = 3xyz$.
  • Random — A randomly generated quiver (no loops or 2-cycles) with a configurable specified number of arrows.
Implementation details

The entire application is self-contained in a single HTML file with inline CSS and JavaScript. No external libraries are used for the core functionality (jsPDF is loaded on demand from a CDN only when PDF export is requested).

Laurent polynomial arithmetic. Cluster variables are represented as Laurent polynomials in $x_1, \ldots, x_n$. Internally, each Laurent polynomial is stored as a JavaScript Map from exponent tuples (e.g. "2,-1,0" for $x_1^2 x_2^{-1}$) to integer coefficients. No external computer algebra system is used—addition, multiplication, exponentiation, and exact polynomial division are all implemented from scratch.

The division step deserves special mention: when computing the exchange relation, we must divide a polynomial by a (potentially complex) Laurent polynomial. This is done via multivariate polynomial long division with lexicographic monomial ordering. The Laurent phenomenon guarantees that this division is always exact (zero remainder), so the algorithm is correct for our use case. Coefficients are rounded to integers after each operation to avoid floating-point drift.

Graph layout. All three graph tabs use a custom force-directed layout algorithm. Nodes are initialized on concentric rings (by BFS depth from the initial node), then iteratively adjusted: a repulsive Coulomb-like force pushes all node pairs apart, an attractive spring force pulls connected nodes together, a node-edge repulsion force prevents nodes from overlapping non-adjacent edges, an edge-crossing repulsion reduces edge intersections, and a mild gravitational pull toward the center prevents drift.

Rendering. All graphics are drawn on HTML5 Canvas elements, scaled by devicePixelRatio for crisp rendering on high-DPI displays. Zoom uses Math.exp(-deltaY * 0.002) for smooth, proportional scrolling on trackpads. Mutation graph nodes are circles containing mini quiver drawings; exchange graph nodes are rounded rectangles showing both the quiver and the $n$ cluster variable expressions; scattering graph nodes are rounded rectangles showing $n$ color-coded vector arrows and the base-mapped tuple coordinates.

Graph construction. All three graphs are built by breadth-first search from the initial node. At each depth level, all $n$ possible mutations are applied to each frontier node. For the mutation graph, nodes are identified by exchange matrix alone; for the exchange graph, nodes are identified by the pair (exchange matrix, cluster variables); for the scattering graph, nodes are identified by base-mapped tuple. A cap of 500 nodes prevents the browser from hanging on deeply explored graphs. Dashed “stub” edges at the frontier indicate mutations that would produce new nodes beyond the current depth.

Last updated: March 3, 2026.