1 Introduction

The notions of the divisorial gonality and stable divisorial gonality of a graph find their origin in algebraic geometry and are related to the abelian sandpile model (cf. [2]). Baker and Norine introduced divisor theory on graphs in [3]. The notion of divisorial gonality was introduced by Baker [4], under the name gonality. As there are several different notions of gonality in use (cf. [4,5,6]), we add the term divisorial, following [5]. See [6, Appendix A] for an overview of the different notions.

Divisorial gonality and stable divisorial gonality have definitions in terms of a chip firing game. In this chip firing game, played on a connected multigraph G = (V, E), each vertex has a number of chips. When we fire a vertex vV, we move a chip from vertex v over each edge with v as endpoint. Vertex v has its number of chips decreased by the degree of v, and each neighbour u of v has its number of chips increased by the number of edges from v to u. The divisorial gonality of a connected graph G can be defined as the minimum number of chips in an initial assignment of chips (called divisor) such that for each vertex vV, there is a sequence of firing moves resulting in at least one chip on v and a non-negative number of chips on the other vertices. See Section 2 for precise definitions.

A variant of divisorial gonality is stable divisorial gonality. The stable divisorial gonality of a graph is the minimum of the divisorial gonality over all subdivisions of a graph; we can subdivide the edges of the graph any nonnegative number of times. (In the application in algebraic geometry, the notion of refinement is used. Here, we can subdivide edges but also add new degree-one vertices to the graph in a refinement, but as this never decreases the number of chips needed, we can ignore the possibility of adding leaves. Thus, we use subdivisions instead of refinements.)

It is known that treewidth is a lower bound for stable divisorial gonality [7]. The stable divisorial gonality of a graph is at most the divisorial gonality, but this inequality can be strict, see for example [8, Figure 2].

In this paper, we study the complexity of computing the stable divisorial gonality of graphs: i.e., we look at the complexity of the Stable Divisorial Gonality problem: given an undirected graph G = (V, E) and an integer k, decide whether the stable divisorial gonality of G is at most k. It was shown in [9] that divisorial gonality is NP-complete. The same reduction gives that stable divisorial gonality is NP-hard. However, membership of stable divisorial gonality in NP is not trivial: it is unknown how many subdivisions are needed to obtain a subdivision with minimum divisorial gonality. In particular, it is open whether a polynomial number of edge subdivisions are sufficient.

In this paper, we show that stable divisorial gonality belongs to the class NP. We use the following proof technique, which we think is interesting in its own right: we give a partial certificate that describes some divisors. Checking whether those divisors are equivalent is non-trivial, but can be done by solving an integer linear program. Membership in NP follows by adding a certificate for the derived ILP instance to the partial certificate that describes the divisors. As a corollary, we have that the total number of subdivisions needed for minimum stable divisorial gonality of a graph with m edges is at most mO(mn).

We finish this introduction by giving an overview of the few previously known results on the algorithmic complexity of (stable) divisorial gonality. Bodewes et al. [8] showed that deciding whether a graph has (stable) divisorial gonality at most 2 can be done in \(O(n \log n +m)\) time. From [10] and [11], it follows that divisorial gonality belongs to the class XP, i.e. there is an algorithm that decides in time O(nf(k)) whether dgon(G) ≤ k. It is open whether stable divisorial gonality is in XP. NP-hardness of the notions was shown in [9].

2 Preliminaries

In this paper, we assume that each graph is a connected undirected multigraph, i.e., we allow parallel edges. In the algebraic number theoretic application of (stable) divisorial gonality, graphs can also have selfloops (edges with both endpoints at the same vertex), but as the (stable) divisorial gonality of graph does not change when we remove selfloops, we assume that there are no selfloops (see the end of this section). For a graph G, we will denote by n its number of vertices and by m the number of edges.

A divisor D is a vector in \(\mathbb {Z}^{V(G)}\). We can consider a divisor D as a function \(D\colon V(G) \to \mathbb {Z}\), which is an assignment of chips to vertices, each vertex v having D(v) chips. The degree of a divisor is the total number of chips on the graph: \(\deg (D) = {\sum }_{v\in V} D(v)\). The support of D is supp(D) = {vVD(v)≠ 0}. We call a divisor effective if D(v) ≥ 0 for all vertices v.

We will define an equivalence relation on the set of divisors. The Laplacian matrix \({\mathscr{L}}\) is defined as follows:

$$ \begin{array}{@{}rcl@{}} \mathcal{L}_{uv} = \left\{\begin{array}{ll} \deg(v) & \text{if}\ u=v,\\ \text{- the number of edges from}\ u\ \text{to}\ v& \text{otherwise.} \end{array}\right. \end{array} $$

Two divisors D and \(D^{\prime }\) are equivalent if and only if there exists a vector \(f \in \mathbb {Z}^{V(G)}\) such that \(D^{\prime }-D = {\mathscr{L}}f\). We can consider f as a function \(f\colon V(G) \to \mathbb {Z}\), we will use the terms vector and function interchangeably.

An equivalent definition can be given using a notion of firing vertices. When we fire a vertex v, we move chips from v to its neighbours along its incident edges: starting from a divisor D, we obtain a new divisor, where D(v) is decreased by the degree of v and for all neighbours u of v the value D(u) is increased by the number of edges from v to u. Two divisors D and \(D^{\prime }\) are equivalent if D can be transformed into \(D^{\prime }\) by firing vertices. This is indeed equivalent to the definition above: f describes how often every vertex is fired.

A divisor D reaches a vertex v if it is equivalent to an effective divisor \(D^{\prime }\) with \(D^{\prime }(v) \geq 1\).

The divisorial gonality dgon(G) of a graph G is the minimum number k such that there exists a divisor D with degree k that reaches all vertices of G. Since D is equivalent to an effective divisor, we can assume D to be effective.

A subdivision of a graph G is a graph H obtained from G by applying the following operation a nonnegative number of times: take an edge between two vertices v and w and replace this edge by two edges to a new vertex x.

The stable divisorial gonality sdgon(G) of a graph G is the minimum number k such that there exist a subdivision H of G and a divisor D on H with degree k that reaches all vertices of H. That is, the stable divisorial gonality of a graph G is the minimum divisorial gonality over all subdivisions of G.

Instead of subdivisions, we can use refinements where we allow that we add subdivisions and trees, i.e., we can repeatedly add new vertices of degree one. But since the stable divisorial gonality does not change when adding a vertex with degree one, we only consider subdivisions.

As mentioned before, we remove selfloops of a graph, as that will not change the stable divisorial gonality. Now that we have seen the definition of stable divisorial gonality we can give a short argument why this holds. Notice that there will never be chips fired along a selfloop, so removing a selfloop will not change the divisorial gonality of a graph. A loop can be subdivided into a cycle however, but this will not decrease the divisorial gonality of the graph. Suppose that G has a loop at vertex v, and that H is the refinement of G at which the stable divisorial gonality is attained by a divisor D. If the selfloop is subdivided, let \(D^{\prime } \sim D\) be a divisor with as few chips on the subdivisions of the loop as possible, that is, with at most 1 chip in total on the vertices that are added to the selfloop. Notice that \(D^{\prime }\) reaches all vertices of H. If we remove the subdivided selfloop from H, firing the same vertices will yield the same result, with possibly some more chips on vertex v. Hence, \(D^{\prime }\) still reaches all vertices. We conclude that the stable divisorial gonality does not increase by removing the selfloops of G.

3 Equivalence

In this section we will discuss a condition for two divisors to be equivalent. This section is based on a result in [7, Section 4], but given its relevance for this paper, we will explain it here.

Recall that two divisors are equivalent if there exists a vector \(f\in \mathbb {Z}^{V(G)}\) such that \(D^{\prime }- D = {\mathscr{L}}f\). We can consider f as a function \(V(G) \to \mathbb {Z}\); f describes for every vertex the number of times this vertex is fired. In this section we will show that we can find an equivalent definition using a function \(g\colon E(G) \to \mathbb {Z}\), which describes for every edge how many chips are moved along that edge.

For an edge uv, we will need to know whether g(uv) describes the number of chips that moves from u to v, or the other way around. For this, we need an orientation of the edges.

Let G = (V, E) be a graph. Assign to every edge e of G an arbitrary orientation σ(e). For every cycle C, and every edge eE let

$$ \begin{array}{@{}rcl@{}} \sigma_{C}(e) = \left\{\begin{array}{lllll} 1 & \text{if}\ e\ \text{is traversed in}\ C\ \text{in the forward direction,}\\ -1 & \text{if}\ e\ \text{is traversed in}\ C\ \text{in the backward direction,}\\ 0 & \text{if}\ e\ \text{is not contained in}\ C. \end{array}\right. \end{array} $$

Analogously, we define σP(e) for every path P. If a path P consists of a single edge uv, we write σuv(e) for σP(e). So,

$$ \begin{array}{@{}rcl@{}} \sigma_{uv}(e) = \left\{\begin{array}{lll} 1 & \text{if}\ e = uv\ \text{is oriented from}\ u\ \text{to}\ v,\\ -1 & \text{if}\ e = uv\ \text{is oriented from}\ v\ \text{to}\ u,\\ 0 & \text{if}\ e\neq uv. \end{array}\right. \end{array} $$

The following lemma is know as Kirchhoff’s potential law, see [12, pages 40, 297]. We include a proof, so that this paper is more self-contained.

Lemma 1

For a function \(g\colon E \to \mathbb {Z}\), there exists a function \(f\colon V\to \mathbb {Z}\) such that for every edge uv, oriented from u to v, it holds that g(uv) = f(u) − f(v) if and only if for every fundamental cycle C:

$$ \begin{array}{@{}rcl@{}} \sum\limits_{e\in C} g(e) \sigma_{C}(e) = 0. \end{array} $$

Proof

We define a function f as follows: Pick a vertex vV, and set f(v) = a for some \(a\in \mathbb {Z}\). For uV, let P be a path from v to u and set

$$ \begin{array}{@{}rcl@{}} f(u) = a - \sum\limits_{e\in P} g(e) \sigma_{P}(e). \end{array} $$

Notice that for f holds that g(uv) = f(u) − f(v). Moreover, every function f for which g(uv) = f(u) − f(v) holds, is of this form.

This function f is well-defined if and only if for all paths P and Q from v to u, it holds that

$$ \begin{array}{@{}rcl@{}} a - \sum\limits_{e\in P} g(e) \sigma_{P}(e) = a - \sum\limits_{e\in Q} g(e) \sigma_{Q}(e). \end{array} $$

Hence, if and only if

$$ \begin{array}{@{}rcl@{}} \sum\limits_{e\in P} g(e) \sigma_{P}(e) + \sum\limits_{e\in Q} g(e) \cdot -\sigma_{Q}(e) = 0. \end{array} $$

Since P followed by Q is reversed order forms a cycle, f is well-defined if and only if for every cycle C:

$$ \begin{array}{@{}rcl@{}} \sum\limits_{e\in C} g(e) \sigma_{C}(e) = 0. \end{array} $$
(1)

Since every cycle is the sum of some fundamental cycles, we conclude that f is well-defined if and only if (1) holds for every fundamental cycle C. □

Now we can provide an equivalent definition for two divisors to be equivalent.

Lemma 2

Let H be a subdivision of G. Let the orientation of the edges of H be induced by the orientation of the edges of G. For every edge eE(G), let l(e) be the number of edges that e is subdivided into in H. Let \(D, D^{\prime }\) be two divisors on G with degree k. Then D and \(D^{\prime }\) are equivalent on H if and only if there exists a function g: E(G) →{−k,−k + 1,…, k − 1, k} such that

  • for every vV (G):

    $$ \begin{array}{@{}rcl@{}}(D^{\prime} - D)(v) = \sum\limits_{u\sim v \text{ in } G} g(uv)\sigma_{vu}(uv), \end{array} $$
    (2)
  • for every fundamental cycle C:

    $$ \begin{array}{@{}rcl@{}} \sum\limits_{e\in C} g(e) l(e) \sigma_{C}(e) = 0. \end{array} $$
    (3)

Proof

Suppose that D and \(D^{\prime }\) are equivalent in H. From the definition in Section 2, we know that there is a function \(f^{\prime }\colon V(H) \to \mathbb {Z}\), such that \({\mathscr{L}}f^{\prime } = D^{\prime }- D\). This function \(f^{\prime }\) describes how often every vertex v is fired to transform D into \(D^{\prime }\).

We now define the function \(g^{\prime }\), this will describe how many chips move over edge e in the forward direction. Let eE(H) and suppose that edge e is directed from u to v, set \(g^{\prime }(e) = f(u)-f(v)\). Notice that \(-k \leq g^{\prime }(e) \leq k\), since there can move at most k chips along each edge. By Lemma 3.1, it follows that for every fundamental cycle C it holds that

$$ \begin{array}{@{}rcl@{}} \sum\limits_{e\in C} g^{\prime}(e) \sigma_{C}(e) = 0. \end{array} $$
(4)

Let e = uv be an edge of G, that is subdivided in e1, e2,…, er edges in H. Let \(w \in V^{\prime }\setminus V\) be a vertex that is added to this edge, and let ei and ei+ 1 be its incident edges. Since D and \(D^{\prime }\) are divisors on G, we see that \(D^{\prime }(w) = D(w) = 0\). It follows that \(g^{\prime }(e_{i}) = g^{\prime }(e_{i+1})\). So for every edge e of G, that is subdivided in e1, e2,…, er edges in H, it holds that \(g^{\prime }(e_{1}) = g^{\prime }(e_{2}) = {\ldots } = g^{\prime }(e_{r})\). Define the function \(g\colon E(G) \to \mathbb {Z}\) by \(g(e) = g^{\prime }(e_{1})\). Notice that \(g(uv) = (f^{\prime }(u) - f^{\prime }(v))/l(e)\).

By the definition of g and the cycle condition (4) for \(g^{\prime }\), it follows that for every fundamental cycle C it holds that

$$ \begin{array}{@{}rcl@{}} \sum\limits_{e\in C} g(e)l(e) \sigma_{C}(e) = 0. \end{array} $$

Moreover, since \({\mathscr{L}}f^{\prime } = D^{\prime }- D\), for every vertex vV (G) we have that

$$ \begin{array}{@{}rcl@{}} (D^{\prime}- D)(v) &=& \mathcal{L}f^{\prime}(v) \\ &=& \deg(v)f^{\prime}(v) - \sum\limits_{u\sim v \text{ in }H} f^{\prime}(u) \\ &=& \sum\limits_{u\sim v \text{ in }H} (f^{\prime}(v) - f^{\prime}(u)) \\ &=& \sum\limits_{u\sim v \text{ in }H} g^{\prime}(uv)\sigma_{vu}(uv) \\ &=& \sum\limits_{u\sim v \text{ in }G} g(uv)\sigma_{vu}(uv). \end{array} $$

For the other direction, suppose that there exists a function \(g\colon E(G) \to \mathbb {Z}\), that satisfies the conditions (2) and (3). By Claim 3.1 it follows that there exists a function \(f\colon V(G) \to \mathbb {Z}\) such that for every edge uvE(G), oriented from u to v, it holds that g(uv)l(uv) = f(u) − f(v).

Define the function \(f^{\prime }\colon V(H)\to \mathbb {Z}\) as follows. For vV (G), set \(f^{\prime }(v) = f(v)\). For every vertex edge e = uvE(G), oriented from u to v, let w1, w2,…, wr be the vertices that are added to e in H, in order from u to v. Set \(f^{\prime }(w_{i}) = f(u) - ig(uv)\).

It remains to check that \({\mathscr{L}}f^{\prime } = D^{\prime }- D\). For wi we see that

$$ \begin{array}{@{}rcl@{}} \mathcal{L}f^{\prime}(w_{i}) &=& 2f(w_{i}) - f(w_{i-1}) - f(w_{i+1}) \\ &=& 0\\ &=& (D^{\prime}- D)(w_{i}). \end{array} $$

For vV (G), we see that

$$ \begin{array}{@{}rcl@{}} \mathcal{L}f^{\prime}(v) &=& \sum\limits_{u\sim v \text{ in }H} (f^{\prime}(v) - f^{\prime}(u)) \\ &=& \sum\limits_{u\sim v \text{ in }G} g(uv) \sigma_{vu}(uv). \end{array} $$

By (2), it follows that \({\mathscr{L}}f^{\prime }(v) = (D^{\prime }-D)(v)\). We conclude that \(D^{\prime }\) and D are equivalent in H. □

4 A Certificate

Assume that we are given a yes-instance (G, k) of the problem. Without loss of generality, we assume that kn. There exists a subdivision H and an effective divisor D on H with k chips that reaches all vertices. We do not know whether the number of subdivisions in H is polynomial in the size of the graph, i.e. in the number of vertices and edges of the graph, so we cannot include H in a polynomial certificate for this instance. But the chips in D can be placed on added vertices of H, so we cannot include D in our certificate either. However, we can include a polynomial subdivision of G. We will choose a subdivision that allows us to include D as well.

Lemma 3

Let G be a graph with n vertices and stable divisorial gonality at most k. There exists a subdivision \(G^{\prime }\) of G, such that

  1. 1.

    The number of vertices of \(G^{\prime }\) is at most n + k(n + 1), i.e., \(G^{\prime }\) is obtained from G by adding at most k(n + 1) subdivision vertices.

  2. 2.

    There is a subdivision H of \(G^{\prime }\), such that there is an effective divisor D on H with k chips that reaches all vertices and has only chips on vertices of \(G^{\prime }\). Moreover, for all vertices vV (G), there is an effective divisor Dv on H with \(D \sim D_{v}\) with at least one chip on v and only chips on vertices of \(G^{\prime }\).

Proof

Since G has stable divisorial gonality at most k, there exists a subdivision H and an effective divisor D on H with k chips that reaches all vertices. For every vertex vV (G), let Dv be an effective divisor on H such that \(D_{v} \sim D\) and that has a chip on vertex v. Now define \(U\subseteq V(H)\) as

$$ \begin{array}{@{}rcl@{}} U = \textup{supp}(D) \cup \bigcup\limits_{v\in V(G)} \{\textup{supp}(D_{v})\}. \end{array} $$

Let \(G^{\prime }\) be the subdivision of G that contains all the vertices of U. Notice that H is a subdivision of \(G^{\prime }\), and that the divisors D and Dv only have chips on \(G^{\prime }\).

Notice that U contains at most (n + 1)k vertices, since we take the union over n + 1 divisors, which each have k chips. So the number of vertices of \(G^{\prime }\) is at most n + k(n + 1). □

Remark 1

Notice that the divisor D could be chosen to be equal to one of the divisors Dv. In that case, U would contain at most kn vertices, and the number of vertices of \(G^{\prime }\) would be improved to n + kn.

This subdivision \(G^{\prime }\) is the first ingredient of our polynomial certificate. The second ingredient is the divisor D, and the third ingredient all divisors Dv.

We now need to extend the certificate so that we can check in polynomial time whether there is a subdivision H of \(G^{\prime }\) such that for all v it holds that \(D \sim D_{v}\) in H. To this end, we will check whether the conditions (2) and (3) in Lemma 3.2 are satisfied. For this, we pick an orientation of the edges of \(G^{\prime }\), and add this to the certificate. Moreover, for every vV (G), we include a function \(g_{v}\colon E(G^{\prime }) \to \{-k, -k+1, \ldots , k-1, k\}\) in the certificate. Now we only need the lengths l(e) of the edges to be able to check the conditions.

This brings us back to the original problem: we do not know whether the number of subdivision is polynomial, hence, we do not know whether the lengths l(e) are polynomial. But we do know that \(D\sim D_{v}\) in H for all v if and only if there exist lengths l(e) such that the conditions on fundamental cycles are satisfied. We make an integer linear program \(\mathcal {I}\) of these equations. So, for every vertex vV (G) and fundamental cycle C in \(G^{\prime }\), we have an equation

$$ \begin{array}{@{}rcl@{}} \sum\limits_{e\in C} g_{v}(e) l(e) \sigma_{C}(e) = 0. \end{array} $$

Moreover, we have an inequality l(e) ≥ 1 for every edge e. This program has a solution if and only if there is a subdivision H of \(G^{\prime }\) such that all divisors Dv are equivalent to D in H. Since integer linear programming is in NP, we know that if there is a solution to \(\mathcal {I}\), then there is a certificate \(\mathcal {D}\) for the ILP instance that is polynomial in the size of \(\mathcal {I}\). Since \(\mathcal {I}\) is polynomial in the size of \(G^{\prime }\), this certificate is polynomial in the size of \(G^{\prime }\) as well. In order to obtain a certificate for the Stable Divisorial Gonality problem, we include this certificate for \(\mathcal {I}\) in the certificate for Stable Divisorial Gonality.

To conclude, a certificate for the Stable Divisorial Gonality problem consists of

  • a subdivision \(G^{\prime }\) of G,

  • an effective divisor D on \(G^{\prime }\),

  • an effective divisor Dv on \(G^{\prime }\) with Dv(v) ≥ 1, for every vV (G),

  • an orientation σ of the edges of \(G^{\prime }\),

  • a function gv for every vV (G), and

  • a certificate for the integer linear program \(\mathcal {I}\).

We can check the correctness of the certificate by checking whether the integer linear program \(\mathcal {I}\) is satisfied and whether for every vV (G) and \(w\in V(G^{\prime })\) the equation

$$ \begin{array}{@{}rcl@{}}(D_{v} - D)(w) = \sum\limits_{u\sim w} g_{v}(uw)\sigma_{wu}(uw) \end{array} $$

holds. This can be done in polynomial time, since there is a polynomial number of equations to check.

5 Correctness

It remains to prove that there exists a certificate \(\mathcal {C}\) if and only if sdgon(G) ≤ k.

Lemma 4

Let G be a graph with sdgon(G) ≤ k. There exists a certificate \(\mathcal {C}\).

Proof

Let n be the number of vertices of G and let m be the number of edges. By Lemma 4.1, there exists a subdivision \(G^{\prime }\), and effective divisors D and Dv on \(G^{\prime }\) for every vV (G), such that there is a subdivision H of \(G^{\prime }\) such that \(D\sim D_{v}\). For every edge \(e\in E(G^{\prime })\), let l(e) be the number of edges that e is subdivided into in H.

Choose an arbitrary orientation σ of the edges of \(G^{\prime }\). Since \(D\sim D_{v}\) for every vertex vV (G), by Lemma 3.2 there exist functions \(g_{v}\colon E(G^{\prime }) \to \mathbb {Z}\) such that for every \(w\in V(G^{\prime })\) holds \((D_{v} - D)(w) = {\sum }_{u\sim w} g_{v}(uw)\sigma _{wu}(uw)\) and for every fundamental cycle C holds \({\sum }_{e\in C} g_{v}(e)l(e)\sigma _{C}(e) = 0\). Now consider the integer linear program \(\mathcal {I}\) with a variable le for every edge \(e\in E(G^{\prime })\), and inequalities le ≥ 1 and for every fundamental cycle C of \(G^{\prime }\) equations \({\sum }_{e\in C} g_{v}(e)l_{e}\sigma _{C}(e) = 0\) for all vV (G). Notice that the number of equations is polynomial, since there are mn + 1 fundamental cycles. We know that l(e) is a solution to this integer linear program. As ILP’s have certificates with polynomially many bits (see e.g., [13]), there exists a polynomial certificate for this program. This yields a polynomial certificate for Stable Divisorial Gonality. □

We illustrate this proof with an example.

Example 1

Consider the graph in Fig. 1a. Consider the subdivision in Fig. 1b and the divisor D with 5 chips on u. This divisor is equivalent to the divisors Dv and Dw in Fig. 1a and f. The graph \(G^{\prime }\) in the certificate is the graph in Fig. 1e.

Fig. 1
figure 1

(a) A graph G. (b) A subdivision of G and divisor D = Du. (c) A divisor Dv. (d) A divisor Dw. (e) The graph \(G^{\prime }\).

Orient e1 from u to y, e2 from y to v, e3 from u to v and e4 from v to w. The corresponding functions are:

$$ \begin{array}{cc c c} g_{u}(e_{1}) = 0, & g_{u}(e_{2}) = 0, & g_{u}(e_{3}) = 0, & g_{u}(e_{4}) = 0 \\\\ g_{v}(e_{1}) = 3, & g_{v}(e_{2}) = 3, & g_{v}(e_{3}) = 2, & g_{v}(e_{4}) = 0 \\\\ g_{w}(e_{1}) = 2, & g_{w}(e_{2}) = 1, & g_{w}(e_{3}) = 1, & g_{w}(e_{4}) = 1 \end{array} $$

The only cycle in \(G^{\prime }\) is e1, e2, e3, so the integer linear program \(\mathcal {I}\) is:

$$ \begin{array}{@{}rcl@{}} l_{e_{1}} \geq 1 , \qquad l_{e_{2}} \geq 1 \\ l_{e_{3}} \geq 1 , \qquad l_{e_{4}} \geq 1 \\ 0\cdot l_{e_{1}} + 0\cdot l_{e_{2}} + 0\cdot l_{e_{3}} &= 0 \\ 3\cdot l_{e_{1}} + 3\cdot l_{e_{2}} + -2\cdot l_{e_{3}} &= 0 \\ 2\cdot l_{e_{1}} + 1\cdot l_{e_{2}} + -1\cdot l_{e_{3}} &= 0 \end{array} $$

A solution to this program is \(l_{e_{1}} = l_{e_{2}} = l_{e_{4}} = 1\) and \(l_{e_{3}} = 3\). This completes the certificate.

Lemma 5

Let G be a graph and k a natural number. If there exists a certificate \(\mathcal {C}\), then sdgon(G) ≤ k.

Proof

Suppose we are given a certificate. Let H be a the subdivision of \(G^{\prime }\) where every edge e is subdivided into l(e) edges. We know that all the equations \((D_{v} - D)(w) = {\sum }_{u\sim w} g_{v}(uw)\sigma _{wu}(uw)\) and \({\sum }_{e\in C} g_{v}(e) l(e) \sigma _{C}(e) = 0\) hold. By Lemma 3.2 it follows that \(D\sim D_{v}\) in H for all vertices vV (G). So D reaches all vertices of G.

Let wV (H) be a vertex which is added to an edge uv of G. Either a chip is fired along e to go from Du to Dv, or there is a divisor \(D_{uv} \sim D\) with a chip on u and a chip on v. In both cases we see that D reaches w. So D reaches all vertices of H. We conclude that sdgon(G) ≤ k. □

By Lemmas 5.1 and 5.3, the problem whether a given graph has divisorial gonality at most a given integer k has a polynomial certificate, which gives our main result.

Theorem 1

Stable Divisorial Gonality belongs to the class NP.

Combined with the NP-hardness of Stable Divisorial Gonality by Gijswijt et al. [9], this yields the following result.

Theorem 2

Stable Divisorial Gonality is NP-complete.

6 A Bound on Subdivisions

In this section, we give as corollary of our main result a bound on the number of subdivisions needed. We use the following result by Papadimitriou [13].

Theorem 3 (Papadimitriou 13)

Let A be an m × n matrix, and b be a vector of length m, such that each value in A and b is an integer in the interval [−a,+a]. If Ax = b has a solution with all values being positive integers, then Ax = b has a solution with all values positive integers that are at most n(ma)2m+ 1.

Corollary 1

Let G be a graph with stable divisorial gonality k. There is a graph H, that is a subdivision of G, with the divisorial gonality of H equal to the stable divisorial gonality of G, and H is obtained from G by subdividing at most mO(mn) times.

Proof

Let \(n^{\prime }\) be the number of vertices in \(G^{\prime }\) and \(m^{\prime }\) the number of edges in \(G^{\prime }\). We have \(n^{\prime }\leq n + k(n+1)\), and \(m^{\prime }\leq m + k(n+1)\), with n the number of vertices of G and m the number of edges of G.

By Lemma 5.1, we know that there is a certificate whose corresponding ILP has a solution. The values le in this solution give the number of subdivisions of edges in \(G^{\prime }\). If we have an upper bound on the number of subdivisions per edge needed to obtain H from \(G^{\prime }\), say α, then (k(n + 1) + 1)α + k(n + 1) is an upper bound on the number of subdivisions per edge to obtain H from G. Applying Theorem 6.1 to the ILP gives such a bound, as described below.

The ILP has at most \(m^{\prime }\) variables of the form le. The number of inequalities in the ILP is linear in the number of variables. An inequality can be replaced by an equation by adding one variable. This gives a total of \(2m^{\prime } = O(m + kn)\) variables. For every edge of \(G^{\prime }\) we have an equation. In addition, for every vertex vV (G) and every fundamental cycle of \(G^{\prime }\), we have an equation. So, the total number of equations is \(m^{\prime } + n(m-n+1)\). Note that \(m^{\prime } + n(m-n+1) = O(mn)\); as G is connected, nm + 1 and kn. Also, note that all values in matrix A and vector b are between − k and k, i.e., we can set a = k in the application of Theorem 6.1. So, by Theorem 6.1, we obtain that if there is a solution to the ILP, then there is one where all variables are set to values at most

$$ O(m+kn) \cdot O(kmn)^{O(mn)} = m^{O(mn)}. $$

We know that there is at least one certificate with a solution, so we can bound the number of subdivisions of \(G^{\prime }\) by mO(mn). This gives that the number of subdivisions per edge of G is at most

$$ \begin{array}{@{}rcl@{}} (k(n+1)+1)m^{O(mn)}+k(n+1) = O(m^{2}) m^{O(mn)} + O(m^{2}) = m^{O(mn)}. \end{array} $$

This results in mmO(mn) = mO(mn) subdivisions in total. □

7 Conclusion

In this paper, we showed that the problem to decide whether the stable divisorial gonality of a given graph is at most a given number k belongs to the class NP. Together with the NP-hardness result of Gijswijt et al. [9], this shows that the problem is NP-complete. We think our proof technique is interesting: we give a certificate that describes some of the essential aspects of the firing sequences; whether there is a subdivision of the graph for which this certificate describes the firing sequences and thus gives the subdivision that reaches the optimal divisorial gonality can be expressed in an integer linear program. Membership in NP then follows by adding the certificate of the ILP to the certificate for the essential aspects.

As a byproduct of our work, we obtained an upper bound on the number of subdivisions needed to reach a subdivision of G whose divisorial gonality gives the stable divisorial gonality of G. Our upper bound still is very high, namely exponential in a polynomial of the size of the graph. An interesting open problem is whether this bound on the number of needed subdivisions can be replaced by a polynomial in the size of the graph. Such a result would give an alternative (and probably easier) proof of membership in NP: first guess a subdivision, and then guess the firing sequences.

There are several open problems related to the complexity of computing the (stable) divisorial gonality of graphs. Are these problems fixed parameter tractable, i.e., can they be solved in O(f(k)nc) time for constant c and some function f that depends only on k? Or can they be proven to be W[1]-hard, or even, is there a constant c, such that deciding if stable divisorial gonality of a given graph G is at most c is already NP-complete? Also, how well can we approximate the divisorial gonality or stable divisorial gonality of a graph?