---
title: Dhar's Burning Algorithm Overview
url: https://www.emergentmind.com/topics/dhar-s-burning-algorithm
type: topic
---

# Dhar's Burning Algorithm Overview

Searching arXiv for the cited papers to ground the article in published sources.
Dhar's burning algorithm is a family of graph-theoretic procedures built around the propagation of a “fire” from a distinguished vertex and used to certify reducedness, effectivity, or failure thereof in chip-firing configurations, and, in a depth-first search variant, to construct a bijection between graph parking functions and rooted spanning trees. In the sources considered here, the term encompasses the classical sink-based test for the Dollar Game, the iterated reduction algorithm for computing $q$-reduced divisors, a modified form adapted to higher gonalities, a weighted-graph generalization, and a depth-first burning process tied to inversion statistics on labeled trees [2407.05158; 2002.07753; 2311.00194; 1309.2201].

## 1. Classical sink-based formulation

In the chip-firing setting, one fixes a finite connected graph $G=(V,E)$ and a distinguished vertex $q\in V$, often called the sink. A divisor is an integer vector $D\in\mathbb{Z}^V$, with $D(v)$ interpreted as the number of chips at $v$; negative entries represent debt. Dhar’s burning algorithm is applied to divisors satisfying $D(v)\ge 0$ for all $v\neq q$, with $D(q)$ possibly negative. Its purpose is to decide whether the Dollar Game at $q$ is winnable, equivalently whether there exists a sequence of chip-firing moves that makes $D(q)\ge 0$ as well [2407.05158].

A single burning phase begins with the burning set $B\leftarrow\{q\}$. Repeatedly, one burns all edges incident to vertices in $B$, and for each vertex $v\notin B$ counts the number $\beta(v)$ of burning edges incident to $v$. If $\beta(v)>D(v)$, then $v$ is added to $B$ and remains there permanently. This continues until no new vertex can be added. If eventually $B=V$, then “the whole graph burns” and the algorithm declares “LOSS.” If instead $B\subsetneq V$, then the unburned complement $S=V\setminus B$ is nonempty, and one fires every vertex of $S$ simultaneously:
$$
D\;\longmapsto\;D+\Delta\,\mathbf{1}_S,
$$
where $\Delta$ is the graph Laplacian and $\mathbf{1}_S$ is the indicator of $S$ [2407.05158].

The key correctness statement is Dhar’s criterion: for a divisor $D$ with $D(v)\ge 0$ for $v\ne q$, the Dollar Game at $q$ is winnable if and only if Dhar’s burning algorithm terminates with “WIN.” Equivalently, “WIN” means that eventually $D(q)$ becomes nonnegative, while “LOSS” means that in some burning phase one obtains $B=V$ [2407.05158].

The primer on chip-firing for Platonic solids gives a complete run on the tetrahedron graph $K_4$. With sink $q=v_2$ and divisor
$$
D=(2,\,-1,\;0,\;0),
$$
the first burning phase yields $B=\{v_2,v_3,v_4\}$ while $v_1$ remains unburned, so one set-fires $S=\{v_1\}$. The new divisor is
$$
(-1,\,0,\,1,\,1),
$$
and now $D(q)=0\ge 0$, so the algorithm returns “WIN” [2407.05158].

## 2. $q$-reduced divisors and iterated burning

A closely related formulation is expressed in terms of $q$-reduced divisors. For a finite (multi-)graph $G$, a divisor $D$ is $q$-semi-reduced if $D(v)\ge 0$ for all $v\neq q$. It is $q$-reduced if, in addition, for every nonempty $A\subset V(G)\setminus\{q\}$ there exists a vertex $v\in A$ such that
$$
D(v)\;<\;\outdeg_A(v),
$$
where $\outdeg_A(v)$ is the number of edges from $v$ to $V(G)\setminus A$ [2002.07753].

In this formulation, Dhar’s algorithm computes the unique $q$-reduced representative $\Red_q(D)$ in the linear-equivalence class of a $q$-semi-reduced divisor. One initializes
$$
W\leftarrow V(G)\setminus\{q\}.
$$
If there exists $v\in W$ with $D(v)<\outdeg_W(v)$, then $v$ burns and is removed from $W$. If no such vertex exists, one fires all of $W$ at once by replacing $D$ with $D-\Delta(\mathbf{1}_W)$, then restarts with $W=V(G)\setminus\{q\}$. When finally $W=\emptyset$, the whole graph has burned and the resulting divisor is $q$-reduced [2002.07753].

This perspective is integrated into the Baker–Norine theory of divisors on graphs through the criterion
$$
r(D)\ge 1\quad\Longleftrightarrow\quad \Red_v(D)(v)\ge 1\;\;\forall v\in V(G),
$$
where $r(D)$ is the rank of the divisor. Consequently, testing rank at least one reduces to computing reduced representatives at each sink vertex [2002.07753].

Termination is proved via a lexicographic potential. Fixing a distance partition $S_0=\{q\},S_1,\dots,S_d$ of the vertex set, one defines
$$
\beta_q(D)\;=\;\bigl(\sum_{v\in S_0}D(v),\;\sum_{v\in S_1}D(v),\;\dots,\;\sum_{v\in S_d}D(v)\bigr).
$$
Each time a nonempty set $W$ is fired, one chip moves strictly closer to $q$ in the lexicographic order on $\beta_q$, so $\beta_q(D)$ increases. Because this vector is bounded above by the total number of chips and the distance parameter $d$, the process terminates [2002.07753].

## 3. Modified burning for higher gonalities

For higher-rank questions, the classical approach is indirect because testing whether $r(D)\ge r$ requires checking $D-E$ for every effective divisor $E$ of degree $r$ and, in the standard formulation, repeating semi-reduction and burning for different sinks. The modified version introduced for gonality sequences is designed to decide whether an arbitrary divisor class contains an effective representative in a single pass, and is described as better suited to testing rank $\ge r$ and hence higher gonalities [2002.07753].

Write an arbitrary divisor as
$$
D\;=\;D^+\;-\;D^-,
$$
with $D^+,D^-\ge 0$. The fire is initialized not at a single sink but on the support of the debt, $\supp(D^-)$. The initial safe set is
$$
W\leftarrow V(G)\setminus\supp(D^-).
$$
As in the classical algorithm, one removes vertices $v\in W$ satisfying $D(v)<\outdeg_W(v)$. If no such vertex exists, one fires the entire safe set:
$$
D\leftarrow D-\Delta(\mathbf{1}_W).
$$
If at any point $D\ge 0$, the algorithm returns an effective divisor $D'\sim D$; if instead the whole graph burns while some vertex remains in debt, it returns **None** [2002.07753].

Three structural differences from the original formulation are explicit. There is no choice of sink $q$; the initial fire is placed on exactly those vertices in debt. There is no separate semi-reduction step, because whenever the algorithm fires the entire safe set $W$, one has $W\cap \supp(D^-)=\emptyset$, so no new debt is introduced. Finally, the algorithm stops early as soon as an effective representative is reached [2002.07753].

The paper’s worked example uses the 8-vertex path
$$
a-b-c-d-e-f-g-h
$$
and the divisor
$$
D=-a+2c+7f-g-2h.
$$
In the first iteration, burning from $\{a,g,h\}$ leaves only $f$ unburned, so $f$ is fired, producing
$$
D'=-a+b+2c+d+e+2f-h.
$$
In the second iteration, burning from $\{a,h\}$ leaves $\{b,c,d,e,f\}$ unburned, and firing that set produces
$$
D''=2a+2g+h,
$$
which is effective. The algorithm therefore returns $D''$ after two passes [2002.07753].

The performance bounds recorded in the source are explicit. Each pass through the fire-loop takes $O(n^2)$ time in the worst case, there are at most $O(n\,\mathrm{diam}(G)\,\deg(D^+))$ passes, and the total time is
$$
O\bigl(n^3\,\mathrm{diam}(G)\,\deg(D^+)\bigr).
$$
The paper notes that, even though the worst-case asymptotic matches the standard algorithm, in practice the modified version is somewhat faster when computing higher gonalities [2002.07753].

## 4. Weighted-graph generalization

Dhar’s burning algorithm has also been generalized to finite, connected weighted multigraphs with no loops and no legs. In this setting one has positive integer vertex weights $w_V:V(\Gamma)\to\mathbb{Z}_+$ and edge weights $w_E:E(\Gamma)\to\mathbb{Z}_+$, subject to the divisibility condition that whenever an edge $e$ has endpoints $u,v$, the weight $w_E(e)$ divides both $w_V(u)$ and $w_V(v)$. The weighted valency is
$$
\val(v)=\sum_{e\text{ incident to }v}\frac{w_V(v)}{w_E(e)}.
$$
A firing at $v$ removes $\val(v)$ chips from $v$ and sends along each incident edge $e=\{v,u\}$ exactly $w_V(v)/w_E(e)$ chips to $u$ [2311.00194].

The corresponding weighted Laplacian $L$ has entries
$$
L_{ii}=\val(v_i),\qquad
L_{ij}=-\sum_{e\in E(v_i,v_j)}\frac{w_V(v_i)}{w_E(e)}\quad(i\ne j),
$$
and linear equivalence is defined by $D'=D-L\sigma$ for an integer firing script $\sigma$. A divisor is $q$-effective if $D(v)\ge 0$ for all $v\neq q$. It is $q$-reduced if it is $q$-effective, has the largest possible value at $q$ among all linearly equivalent $q$-effective divisors, and, when another $q$-effective representative has the same value at $q$, any nontrivial firing script from $D$ to that representative must fire $q$ at least once [2311.00194].

The weighted algorithm introduces the charge vector. Let
$$
C=\operatorname{lcm}_{v\in V} w_V(v),\qquad c(v)=\frac{C}{w_V(v)}.
$$
The script $\sigma^*$ with $\sigma^*(v)=c(v)$ lies in $\ker L$ and generates it. The generalized burning algorithm starts by setting $\sigma(v):=c(v)$ for each $v\neq q$, then loops over $f=0,\dots,c(q)-1$, setting $\sigma(q):=f$. At each stage one computes $D'=D-L\sigma$ and declares that a vertex $v$ burns precisely when
$$
(D-L\sigma)(v)<0.
$$
Burning reduces $\sigma(v)$ by $1$, and after all such reductions stabilize, the algorithm records the resulting candidate. Among the $c(q)$ candidates, it chooses the one maximizing the residual value at $q$ [2311.00194].

Termination follows because the outer loop runs at most $c(q)$ times, while in the inner loop each coordinate $\sigma(v)$ begins at $c(v)\ge 0$ and can be decreased only finitely many times. The overall bound stated in the paper is $O\!\left(c(q)\sum_{v\ne q}c(v)\right)$ burning steps, and with the cost of computing $D-L\sigma$ this yields time complexity
$$
O\!\left(m\cdot c(q)\cdot \sum_{v\ne q} c(v)\right),
$$
where $m=|E|$ [2311.00194].

The weighted formulation also changes the structural picture. The source emphasizes that the Laplacian is generally not symmetric, that the outer loop of size $c(q)$ is needed to search for the script leaving the maximum possible number of chips at $q$, and that there can be more than one $q$-reduced representative in a single linear-equivalence class when $c(q)>1)$ [2311.00194].

## 5. Depth-first burning, parking functions, and tree inversions

A different but closely related procedure appears in the study of $G$-parking functions and labeled spanning trees. Here $G=(V,E)$ is a finite, connected, simple graph with distinguished root $r\in V$, and a $G$-parking function is a map
$$
P:V\setminus\{r\}\to\mathbb{N}_0
$$
such that for every nonempty $S\subseteq V\setminus\{r\}$ there exists $i\in S$ with
$$
P(i)<\deg_{S^c}(i),
$$
where $\deg_{S^c}(i)$ is the number of edges joining $i$ to a vertex outside $S$ [1309.2201].

The depth-first search version of Dhar’s burning algorithm lights the root $r$ on fire and lets the fire spread according to a depth-first rule. Each nonroot vertex $i$ carries $P(i)$ drops of water. When the fire arrives at $i$ along an edge $e$, two cases occur. If $P(i)>0$, one uses one drop of water, replaces $P(i)$ by $P(i)-1$, dampens $e$, and immediately backtracks. If $P(i)=0$, then $i$ is permanently burnt, the edge $e$ is recorded as a tree edge, and the search continues from $i$, always choosing the largest-labeled unburnt neighbor next [1309.2201].

This process yields a dichotomy. If every vertex burns, then exactly $n$ edges burn through, forming a spanning tree $T$ rooted at $r$, and the number of dampened edges is $\sum P(i)=\deg(P)$. If instead some set $S$ never burns, then each $j\in S$ has every edge to a burnt vertex dampened, so $P(j)\ge \deg_{S^c}(j)$, certifying that $P$ is not a parking function [1309.2201].

The inverse procedure starts from a rooted spanning tree $T$ and runs the same depth-first skeleton, dampening every non-tree edge encountered in the same order and incrementing $P(j)$ whenever $j$ is the head of a dampened edge. The two procedures are inverse to one another, producing a bijection
$$
\phi:\mathrm{PF}\to\mathrm{SPT}.
$$
The central enumerative statement is the degree–inversion correspondence. If
$$
g=|E|-|V|+1
$$
is the circuit rank, and $\kappa(G,T)$ denotes the number of $\kappa$-inversions of the rooted spanning tree $T$, then
$$
\kappa(G,\phi(P))=g-\deg(P),
$$
or equivalently
$$
\deg(P)+\kappa(G,\phi(P))=g.
$$
The paper states this as its main theorem and notes that, when specialized to the complete graph, it answers a problem posed by R. Stanley [1309.2201].

The worked “house” example takes the root $0$ and the parking function $P=(0,0,1,0)$ on vertices $\{1,2,3,4\}$. The burn produces the rooted spanning tree with edges
$$
\{0\to 2,\;2\to 4,\;2\to 3,\;3\to 1\},
$$
with a single dampened edge $(4\to 3)$. Hence $\deg(P)=1$. Since the graph has $g=6-5+1=2$, one checks that $\kappa(G,T)=1$, in accordance with $\kappa(G,T)=g-\deg(P)$ [1309.2201].

## 6. Applications, scope, and algorithmic significance

The applications recorded in these sources are concentrated in chip-firing, graph gonality, and spanning-tree enumeration. In the primer on Platonic solids, Dhar’s burning algorithm is one of the main tools used alongside independent sets, treewidth, and scramble number; that work presents the first proofs that the dodecahedron graph has gonality $6$ and that the icosahedron graph has gonality $9$ [2407.05158].

Within gonality computations, the algorithm serves both as a decision procedure and as a source of lower-bound arguments. The primer explicitly refers to “Dharguments,” meaning variations on Dhar’s algorithm used to obtain quick lower bounds on gonality by showing that any small-degree divisor will trigger a full burn from a suitable choice of sink. The modified version for gonality sequences extends this role from rank at least one to higher-rank questions by solving the general “dollar-game” problem of deciding effectivity in one pass [2407.05158; 2002.07753].

Algorithmically, the formulations represented here range from linear-time depth-first search on simple graphs to polynomial-time chip-firing procedures on divisors and more elaborate weighted variants. The DFS-burning bijection runs in $O(|V|+|E|)$, the classical burning phase can be implemented in $O(|E|+|V|)$ time, the iterated set-firing process is polynomial in the graph size and chip magnitudes, and the weighted version has complexity governed by the charge parameters $c(v)$ induced by the vertex weights [1309.2201; 2407.05158; 2311.00194].

Taken together, these formulations show that “Dhar’s burning algorithm” is not a single fixed routine but a coherent method family. In every version, a burn from a distinguished source exposes whether a configuration can resist propagation. What changes across the literature is the object being tested—Dollar Game solvability, $q$-reducedness, existence of an effective divisor in a linear-equivalence class, or membership in a parking-function class—and the output, which may be a win/loss certificate, a reduced divisor, a legal firing script, or a rooted spanning tree endowed with inversion statistics [2407.05158; 2002.07753; 2311.00194; 1309.2201].

Source: https://www.emergentmind.com/topics/dhar-s-burning-algorithm