Abstract 1 Introduction 2 Preliminaries 3 Warm Up: Integral Target Density 4 Algorithmic Results 5 NP-hardness Results 6 Conclusion References

Density Matters: A Complexity Dichotomy of Deleting Edges to Bound Subgraph Density

Matthias Bentert ORCID Technische Universität Berlin, Germany
University of Bergen, Norway
Tom-Lukas Breitkopf ORCID Algorithmics and Computational Complexity, Technische Universität Berlin, Germany Vincent Froese ORCID Algorithmics and Computational Complexity, Technische Universität Berlin, Germany Anton Herrmann ORCID Algorithmics and Computational Complexity, Technische Universität Berlin, Germany André Nichterlein ORCID Algorithmics and Computational Complexity, Technische Universität Berlin, Germany
Abstract

We study τ-Bounded-Density Edge Deletion (τ-BDED), where given an undirected graph G, the task is to remove as few edges as possible to obtain a graph G where no subgraph of G has density more than τ. The density of a (sub)graph is the number of edges divided by the number of vertices. This problem was recently introduced and shown to be NP-hard for τ{2/3,3/4,1+1/25}, but polynomial-time solvable for τ{0,1/2,1} [Bazgan et al., JCSS 2025]. We provide a complete dichotomy with respect to the target density τ:

  1. 1.

    If 2τ (half-integral target density) or τ<2/3, then τ-BDED is polynomial-time solvable.

  2. 2.

    Otherwise, τ-BDED is NP-hard.

We complement the NP-hardness with fixed-parameter tractability with respect to the treewidth of G. Moreover, for integral target density τ, we show τ-BDED to be solvable in randomized O(m1+o(1)) time. Our algorithmic results are based on a reduction to a new general flow problem on restricted networks that, depending on τ, can be solved via Maximum s-t-Flow or General Factors. We believe this connection between these variants of flow and matching to be of independent interest.

Keywords and phrases:
Transshipment, Maximum Flow, General Factors, Matching, Graph Modification Problem
Copyright and License:
[Uncaptioned image] © Matthias Bentert, Tom-Lukas Breitkopf, Vincent Froese, Anton Herrmann,
and André Nichterlein; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Parameterized complexity and exact algorithms
; Theory of computation Problems, reductions and completeness ; Mathematics of computing Matchings and factors ; Mathematics of computing Network flows
Related Version:
Full Version: https://arxiv.org/abs/2601.03129
Funding:
The research leading to these results has received funding from the European Research Council (ERC) under the European Union’s Horizon 2020 research and innovation program (grant agreement No. 819416) and the German Research Foundation (DFG, grant 1-5003036: SPP 2378 – ReNO-2).
Editors:
Meena Mahajan, Florin Manea, Annabelle McIver, and Nguyễn Kim Thắng

1 Introduction

Finding a densest subgraph in a given undirected graph is an “evergreen research topic” [16]. The density of a (sub)graph is the number of edges divided by the number of vertices, which is equal to half the average degree. A graph with n vertices can thus have a density up to (n1)/2; with this maximum being reached if and only if the graph is a clique. While a reader unfamiliar with the problem might suspect it to be NP-hard – like Clique – it can in fact be solved in polynomial time: This was first discovered 1979 and published 1982 by Picard and Queyranne [19] with an algorithm based on maximum-flow computations (cf. Lanciano et al. [16]). An improved algorithm due to Goldberg [12] also relies on a maximum s-t-flow.

In this work, we study the following closely related problem called τ-Bounded-Density Edge Deletion (τ-BDED) where τ0: Given an undirected graph G=(V,E), delete as few edges as possible such that the densest subgraph of the remaining graph has density at most τ. This problem was recently introduced by Bazgan et al. [3], who observed that for τ<1 the remaining graph has to be a forest where each tree can have at most 1/(1τ) vertices. Thus, τ-BDED generalizes the polynomial-time solvable Maximum Cardinality Matching (τ=1/2) and the NP-hard Perfect P3-Packing (τ=2/3). For τ>1, not much is known about the complexity of τ-BDED beyond NP-hardness for τ slightly above 1 (τ=1+1/c with c being any constant larger than 24 [3]).

Our main result is a complete complexity dichotomy for τ-BDED:

Theorem 1.1.

If 2τ or τ<2/3, then τ-Bounded-Density Edge Deletion is polynomial-time solvable, otherwise it is NP-hard. Moreover, if τ, then it is solvable in randomized O(m1+o(1)) time.

Additionally, we show fixed-parameter tractability for the parameter treewidth. To this end, note that for a graph of treewidth tw a tree decomposition of width tw can be computed in time 2O(tw2)nO(1) [15] and a tree decomposition of width 2tw+1 in time 2O(tw)n [14].

Theorem 1.2.

τ-Bounded-Density Edge Deletion is fixed-parameter tractable with respect to treewidth. Given a tree decomposition of width tw with τ=ab, it can be solved in time (max{a,b}+1)tw+1nO(1).

On the technical side, we follow the line of Picard and Queyranne [19] and Goldberg [12]: We achieve our algorithmic results by efficiently reducing to a generalized flow problem (which we call 2-Layer General Transshipment (2GT)). For integral target density τ, 2GT can be solved with a simple maximum s-t-flow computation in a linear-size network with small integer capacities (at most τ). This allows employing recent algorithms for computing maximum flows [7] to solve τ-BDED with τ in randomized O(m1+o(1)) time on graphs with m edges. For τ=1/2, our flow approach to solve the 2GT instance fails. The reason is that we rely on a maximum flow being integral and some arcs having capacity τ. In such cases, a simple scaling of capacities yields integer values. However, our flow-problem then gets an additional constraint that some arcs either transport a full flow (equal to the capacity) or no flow at all. These “all-or-nothing” restrictions render the Maximum Flow problem NP-hard in general, even if all arcs have integer capacities of at most two.111While we did not find this statement in the scientific literature, an NP-hardness proof was given by Neal Young on stackexchange: https://cstheory.stackexchange.com/questions/51243/maximum-flow-with-parity-requirement-on-certain-edges. The full proof is included in the full version of this paper. The restricted network structure (being bipartite with all arcs directed towards one partition) in our flow problem, however, allows a reduction to General Factors, which is a generalization of Maximum Cardinality Matching. Note that this reverses the standard approach of solving Maximum Cardinality Matching in bipartite graphs by a reduction to Maximum Flow [21]. Leveraging known algorithmic results for General Factors, we obtain a polynomial-time algorithm for half-integral target density τ and fixed-parameter tractability with respect to treewidth.

Related Work.

We refer to the survey of Lanciano et al. [16] for an overview over Densest Subgraph and various approaches to solve it and its variants.

To the best of our knowledge, so far only Bazgan et al. [3] investigated Bounded-Density Edge Deletion (BDED), the problem variant of τ-BDED where the target density is part of the input and can thus depend on n. Bazgan et al. used the allowed dependency on n to prove W[1]-hardness of BDED with respect to treewidth [3] (the proof requires a target density τ=11/o(n)). Considering the relation between the choice of τ and the computational complexity of the problem, they obtained the following results: BDED is NP-hard in case τ[23,34] or τ=1+1c, where c is any constant larger than 24, but BDED becomes polynomial-time solvable in case τ<23 or τ[11n,1].

The vertex deletion variant of BDED is called Bounded-Density Vertex Deletion (BDVD) and generalizes Vertex Cover (τ=0) and Feedback Vertex Set (τ=11/n). It was also introduced by Bazgan et al. [3], who showed the following results: BDVD is NP-hard for any constant target density. Both BDED and BDVD are fixed-parameter tractable with respect to the vertex cover number, but W[1]- respectively W[2]-hard with respect to the solution size, that is, the number of edges, respectively vertices, to remove.

Chandrasekaran et al. [5] studied the approximability of BDVD. Interestingly, they (also) focus on integral target density τ2 and provide a polynomial-time O(logn)-approximation that cannot be improved to a factor of o(logn) assuming PNP. Their approximation algorithm indeed solves more general problems like Supermodular Density Deletion and Matroid Feedback Vertex Set.

Organization.

After introducing basic notions in Section 2, we provide an easy flow-construction for integral target density τ as warm-up in Section 3. We show our main result on the generalized flow variant in Section 4 and complement our findings with NP-hardness results for τ-BDED in Section 5 for the remaining target densities. We conclude in Section 6.

2 Preliminaries

We set :={0,1,} to include 0 and denote by 0+:={qq0} (0:={qq0}) the set of non-negative (non-positive) rational numbers. For n, we define [n]{1,2,,n} with [0]:=. We use to denote the set of all non-negative half-integral rational numbers, that is, ={q2q}.

Graph & Digraphs.

All graphs in this work are simple and unweighted. Let G be an undirected graph and D be a digraph. We denote the set of vertices of G and D by V(G) and V(D) and the set of edges of G and arcs of D by E(G) and A(D), respectively. For C{G,D}, we denote with nC and mC the number of vertices and edges (arcs) of C. We denote the degree of a vertex vV(G) by degG(v)|N(v)|, where N(v){uV(G){u,v}E(G)}. Similarly, we denote the in-degree (out-degree) of a vertex vV(D) by degD(v)|N(v)| (degD+(v)|N+(v)|), where N(v){uV(D)(u,v)A(D)} (N+(v){uV(D)(v,u)A(D)}). If the considered graph is clear from the context, then we drop the subscripts. We write HG to denote that H is a subgraph of G. For a subset EE(G), we write GE for the subgraph of G obtained by deleting the edges in E. We denote by Kn the complete graph on n vertices (also called a clique of order n).

The density of G is ρ(G)m/n, where the density of the empty graph is defined as zero. We denote by ρ(G) the density of the densest subgraph of G, that is, ρ(G)maxHGρ(H). A graph G is balanced if ρ(H)ρ(G) for every subgraph HG; this implies ρ(G)=ρ(G). We study the following problem, which is defined for every rational τ0:

τ-Bounded-Density Edge Deletion (τ-BDED)
Input: An undirected graph G and an integer k.
Question: Is there a subset FE(G) with |F|k such that ρ(GF)τ?

Throughout the rest of this work we assume G to be connected and hence have nG1mG and O(mG+nG)=O(mG). Clearly, if G is not connected we can obtain a solution by solving each connected component individually and isolated vertices can be ignored.

Fractional Orientations.

A crucial tool in our subsequent proofs and approaches are orientations, which follow from a dual LP formulation by Charikar [6, Section 3.1] to compute the density of a densest subgraph. An orientation of an undirected graph G assigns a direction to each edge {u,v}, that is, {u,v} is replaced either by (u,v) or by (v,u). Charikar [6] observed that the maximum indegree in any orientation of G is an upper bound for ρ(G). This is also true for fractional orientations where we assign some part of an edge {u,v} to u and the rest to v. More formally, a fractional orientation ϕ assigns to each edge e={u,v} two non-negative rationals ϕ(e)u and ϕ(e)v with ϕ(e)u+ϕ(e)v=1. We denote with

degϕ(v)uN(v)ϕ({u,v})v and ΔϕmaxvV(G)degϕ(v)

the indegree of a vertex vV(G) and the maximum indegree of G with respect to the fractional orientation ϕ. From now on we write ϕ(uv)v as a short-hand for ϕ({u,v})v.

We restate the aforementioned property as a lemma together with a stricter formulation.

Lemma 2.1.

For every graph G and fractional orientation ϕ, it holds that ρ(G)Δϕ.

Lemma 2.2 (Charikar [6]).

For every graph G, there is a fractional orientation ϕ with ρ(G)=Δϕ.

It follows from the work of Charikar [6] and the fact that LPs can be solved in polynomial time [21], that an orientation ϕ with ρ(G)=Δϕ can be computed in polynomial time.

Flows and Factors.

Studied for well over half a century Maximum Flow is still subject of active research [7]. We refer to standard text books for an overview on flows [1, 21] and subsequently recall very briefly only the most relevant notions and concepts. In the basic setting, we are given a directed graph D forming the flow network with two distinguished vertices s,tV(D) and arcs that are equipped with capacities cap:A(D)0+. A flow f:A(D)0+ assigns to each arc aA(D) a non-negative amount of flow f(a)cap(a) such that for each vertex vV(D){s,t} the amount fΣ(v):=uN(v)f(u,v) of flow entering v is equal to the amount fΣ+(v):=uN+(v)f(v,u) of flow leaving v. Here, and throughout the paper, we write f(a,b) as a short-hand for f((a,b)). The excess of the flow at v is fΣ(v):=fΣ+(v)fΣ(v), that is, s and t are the only vertices with non-zero excess. The value of a flow is defined as val(f)=fΣ(s)=fΣ(t).

Many extensions on the basic Maximum Flow have been studied, including costs on arcs, multiple sources and sinks, or lower bounds on the flow amount for the arcs (to name just a few). Computing maximum flows respecting all these restrictions can be done in polynomial time [1, 21]. Computing a maximum flow that is even on all arcs (while still respecting capacities) is still doable in polynomial time (and seems a common exercise given the online search results). However, restricting a subset FA(D) of arcs to have either flow 0 or 2 is already sufficient make the problem NP-hard (see full version of the paper).

In contrast to maximum flow, the following Matching generalization is still polynomial-time solvable if restricted to even (or odd) numbers.

General Factors
Input: An undirected graph G, a collection of sets ={Bv{0,1,,degG(v)}vV(G)}.
Question: Is there a subset FE(G), such that deg(V(G),F)(v)Bv for every vertex vV(G)?

We call a solution F a factor of (G,). General Factors with Bv={1} for each vertex v is exactly Perfect Matching. Cornuéjols [8] showed that General Factors is polynomial-time solvable if the maximum gap in any Bv is of length at most one. Here, an integer subset B has a gap of length d1 if there exists an integer pB with p+1,,p+dB but p+d+1B. For example, the set {0,2,3,5} has gaps of length one as certified by p=0 and p=3. We denote by max-gap the maximum gap length over all sets Bv. Note that a max-gap of one is the boundary of polynomial-time solvability: There is a straightforward reduction from the NP-hard Exact Cover by 3-Sets [11, problem SP2] to General Factors where every vertex v has allowed degrees either Bv={0,3} (the vertex represents a set) or Bv={1} (the vertex represents an element) [8]. Clearly, the constructed instance has max-gap two.

Recently, Marx et al. [17] provided an algorithm for General Factors running in (M+1)3tw time on graphs of treewidth tw, where M is the largest integer appearing in any set Bv.

3 Warm Up: Integral Target Density

Consider a τ-Bounded-Density Edge Deletion instance =(G,k) with integral target density τ. We transform into a Maximum Flow instance with O(mG) vertices and arcs and small integral capacities. As a maximum flow in such networks can be computed in randomized O(m1+o(1)) time [7], we get a near-linear time algorithm for τ-BDED if τ.

The flow shall correspond to a fractional orientation. That is, one unit of flow should leave each edge {u,v}; a part of it flowing to u, the rest to v. Moreover, at each vertex v a total flow of at most τ is allowed to arrive. This idea easily translates to the following construction of the flow network D (see Figure 1 for a visualization of the construction):

Figure 1: Example transformation of a τ-BDED instance with τ (on the left) to a flow instance (on the right). All arcs on the same layer of the flow network have the same capacity as indicated at the leftmost arc.
  • Set the vertex set of D as V(D)=V(G)E(G){s,t}. This means for every vertex in G as well as every edge in G, there is a vertex in D.

  • For every e={u,v}E(G) add an arc with capacity 1 to D going from source s to vertex e.

  • For every vV(G) add an arc with capacity τ to D going from v to sink t.

  • For every edge e={u,v}E(G) add two arcs with capacity 1 to D, one going from vertex e to vertex u and one going from e to v.

Consider a maximum s-t-flow f in the constructed network D. Since all capacities are integral, it follows that f is integral [1, 21]. It is not hard to see that we have val(f)=mG (that is, all arcs leaving s transport a flow of 1) if and only if there is a fractional orientation ϕ in G with Δϕτ; the flow on the arcs in E(G)×V(G) corresponds to ϕ. However, a stronger statement holds: There is a solution FE(G) for of size |F|=k if and only if f has value mGk . The correspondence between f and F becomes clear at the arcs incident to s: For an edge eE(G) we have f(s,e)=0 if and only if eF. We defer the formal proof of this statement to the next section (see Lemma 4.1), where we provide a transformation to a more general flow-variant that covers also non-integral target densities.

Note that the flow network D has size O(mG+nG)=O(mG) and can be constructed in linear time. Moreover, the largest reasonable value for τ is (nG2). Using fast existing maximum-flow algorithms for polynomially bounded integral capacities [7], we obtain the following:

Theorem 3.1.

There is a randomized algorithm solving τ-Bounded-Density Edge Deletion with integral target density τ in time O(m1+o(1)).

A further consequence of the flow-construction is that if τ, then there exists a fractional orientation that is in fact integral. That is, each edge is assigned to either of its two endpoints. This was previously observed by Chandrasekaran et al. [5].

Note that for τ=1/2 the capacities in D are no longer integral. Therefore, an integral maximum flow is not guaranteed. However, τ-BDED for τ=1/2 corresponds to Maximum Cardinality Matching. Hence, for our particular network D there is a polynomial-time algorithm that computes among all flows that are integral on the arcs leaving s a maximum one. Note that a linear-time reduction from Maximum Cardinality Matching to Flow is not known (so far). Thus, a polynomial-time algorithm for τ-BDED with half-integral capacities cannot rely on such a simple reduction as provided above. We present the solution to this issue in the next section.

4 Algorithmic Results

In this section, we provide efficient algorithms for τ-BDED with certain target densities. More precisely, we provide polynomial-time algorithms for integral and half-integral target densities, while for arbitrary constant target densities, we prove fixed-parameter tractability with respect to the treewidth of the input graph. Our approach builds on the overall idea of Section 3, that is, we reduce τ-BDED to some kind of flow problem. In particular, we introduce the 2-Layer General Transshipment (2GT) problem, which is, informally spoken, a flow problem on graphs with multiple source and sink vertices, where every edge goes directly from a source to a sink and every vertex has a set of allowed excess values. Afterwards, we translate this problem to General Factors. Applying known results for General Factors, we finally deduce algorithmic results for 2GT, which, on the one hand, are of interest on their own and, on the other hand, can then be translated to τ-BDED.

4.1 Transshipment Formulation

To describe τ-BDED more generally, we switch to transshipment problems, that is, a flow-variant where we have multiple sources and sinks with specified amounts of flow that are provided resp. consumed by the sources and sinks [21]. Consider a digraph D. For a function b:V(D), a b-transshipment is a flow f with fΣ(v)=b(v) for all vertices vV(D). Note that vVb(v)=0 is necessary for a b-transshipment to exist. Adapting notation from General Factors, we specify a set collection ={BvvV(D)} of allowed excess values for each vertex. A -transshipment is then a (flow) function f:A(D)0+ with fΣ(v)Bv for all vV(D). Note that if also arc capacities cap:A(D)0+ are provided, then we have the usual additional requirement f(a)cap(a) for each arc aA(D). We call an instance (D,cap,) integral if cap:A(D) and Bv for all vV(D). We call a digraph D 2-layered, if the underlying undirected graph is bipartite with parts U and W and all arcs go from U to W, that is, A(D)U×W. For a 2-layered network D with vertex partitions U and W and flow f, we define the value val(f)=uUfΣ(u)=wWfΣ(w). Note that in a 2-layered transshipment instance, we can assume that the vertices in U are sources (non-negative excess) and the vertices in W are sinks (non-positive excess). With these notions, we can define our transshipment problem:

2-Layer General Transshipment (2GT)
Input: A 2-layered network D with parts U and W, arc capacities cap:A(D)0+, and a collection ={Bv0+vU}{Bv0vW} of sets.
Task: Find a -transshipment f in D which maximizes val(f).

For the rest of this work we assume the underlying undirected graph of D to be connected and therefore have nD1mD and O(mD+nD)=O(mD). Clearly if this is not the case, we obtain a solution by solving each connected components individually and isolated vertices can be ignored. To familiarize ourselves with the problem, let us model an instance =(G,k) of τ-BDED as a 2GT-instance; we denote this linear-time transformation by T():

  • The vertex set of the network D is V(D)V(G)E(G).

  • For each edge e={u,v}E(G), add the arcs (e,u) and (e,v) with capacity 1 to D.

  • For each eE(G), set Be{0,1}, that is, a flow of either 0 or 1 is allowed to leave e.

  • For each vV(G), set Bv[τ,0], that is, any flow up to τ is allowed to arrive in v.

Note that in the above construction a vertex vV(G) is assigned an infinitely large set [τ,0] of allowed excess values. We henceforth assume that a reasonable encoding for the sets Bv is used (here, e. g. via the numbers τ and 0 encoding the interval).

It is straightforward to verify the correctness of this reduction:

Lemma 4.1.

Let =(G,k) be a τ-BDED instance and let T()=(D,cap,) be the constructed 2GT instance. Then there is a -transshipment f in D with value val(f)mGk if and only if there is an edge set FE, |F|k, with ρ(GF)τ.

Proof.

”:

Suppose that f is a -transshipment for (D,cap,) with val(f)mGk. We define FE(G) to be the set of edges where no flow is sent from the corresponding vertices in D, that is, F:={eE(G)fΣ(e)=0}. Since fΣ(e)Be={0,1} for all eE(G) and val(f)mGk, it follows that |F|k.

Using the flow f, we now construct a fractional orientation ϕ for GF with Δϕτ. Lemma 2.1 then yields the claim. For any edge e={u,v}E(G)F, consider the arcs (e,u) and (e,v) in A(D). Set ϕ(e)u:=f(e,u) and ϕ(e)v:=f(e,v). It holds that ϕ(e)u+ϕ(e)v=1, since fΣ(e)=1. For any vertex vV(G), it holds that degϕ(v)τ, because fΣ(v)τ by the excess constraint Bv=[τ,0].

”:

Now, let FE(G), |F|k, with ρ(GF)τ. By Lemma 2.2, there exists a fractional orientation ϕ on GF with Δϕτ. We construct a -transshipment f with val(f)mGk from ϕ: For each e={u,v}E(G)F, set the flows f(e,u)ϕ(e)u and f(e,v)ϕ(e)v, and for each e={u,v}F, set f(e,u)=f(e,v)0. Consider the vertices in V(D) representing the edges of E(G). The above assignment ensures for any vertex eE(G)F, that fΣ(e)=1 and for any vertex eF that fΣ(e)=0. Moreover, fΣ(v)[τ,0] is guaranteed since Δϕτ. Finally, we have val(f)=eEF1=mG|F|mGk.

4.2 Solving 2-Layer General Transshipment via General Factors

We now consider how to solve 2GT using General Factors. One important step will be to limit the excess constraints of vertices in a 2GT instance to integral values. For this, we first consider conditions under which 2GT yields integral solutions, meaning solutions in which the flow assigned to any edge is integral.

Lemma 4.2.

Let (D,cap:A(D),) be a 2GT instance with A(D)U×W. Furthermore, for each vV(D), let Bv or Bv=[cv,dv] for some cv,dv with cvdv. If (D,cap,) has a -transshipment, then it attains an integral maximum -transshipment.

Proof.

The idea is to construct a flow instance with lower and upper bounds for the flow on each arc, then use a known integrality property and finally transfer the flow back to our 2GT instance. Let f be a maximum -transshipment for (D,cap,) (such f must exist if there is a feasible transshipment) and consider the flow instance , where we take the network D together with a source vertex s, a sink vertex t and the following arcs with lower and upper bounds (denoted by intervals) on the flow assigned to them:

  • For each arc aA(D), we set the permitted flow to [0,cap(a)].

  • For every uU with fΣ(u)>0, we add the arc (s,u) and distinguish between two cases. If Bu=[cu,du], then we set the permitted flow to [cu,du]. Otherwise, we set the permitted flow to [fΣ(u),fΣ(u)].

  • For every wW with fΣ(w)<0, we add the arc (w,t) and distinguish between two cases. If Bw=[cw,dw], then we set the permitted flow to [dw,cw] and otherwise to [fΣ(w),fΣ(w)].

We now show that there is a feasible flow f for the constructed instance, which then implies the existence of an integral maximum flow for (see [21, Corollary 11.2e]). Let a be some arc in our constructed instance. We define f by

f(a){fΣ(u)if a=(s,u) for some uUf(a)if aA(D)fΣ(w)if a=(w,t) for some wW.

Note that val(f)=val(f) since both flows send the same amount of flow from U to W. The feasibility of f follows directly from our construction and the fact that f is a -transshipment. Now, let f′′ be an integral maximum flow for . We define an integral -transshipment f by f(u,w):=f′′(u,w) for all (u,w)A(D).

First, we show that f is indeed a -transshipment. For this, note that for each uU, we have fΣ(u)=f′′(s,u). We distinguish between two cases. If Bu, then the permitted flow on (s,u) is exactly fΣ(u) and therefore f′′(s,u)=fΣ(u)Bu. Otherwise, the permitted flow on (s,u) is [cu,du] which directly implies f′′(s,u)[cu,du]=Bu. For all vertices wW, we have fΣ(w)=f′′(w,t) and by analogous arguments as above, it follows f′′(w,t)Bw.

It remains to show that f is indeed a maximum flow. Recall that f is a maximum flow for (D,cap,) and f with val(f)=val(f) is a feasible solution for . Further, f′′ is a maximum integral flow for , that is, val(f)val(f′′). Finally, since val(f)=val(f′′), we have val(f)=val(f)val(f′′)=val(f).

Using the above lemma we now observe that any 2GT instance with an integral maximum transshipment can be restricted to integral capacities and integral excess values.

Observation 4.3.

If a 2GT instance (D,cap,) has an integral maximum -transshipment, then it is equivalent to (D,cap,) where {BvBv} and cap(a)cap(a) for each arc aA(D).

With this observation we can now describe a reduction of integral 2GT instances to General Factors. This will later allow us to use known algorithms for General Factors to solve 2GT instances.

Lemma 4.4.

Let (D,cap:A(D),={BvvV(D)}) be an integral 2GT instance, where all capacities are bounded polynomially in the size of D. Then, one can construct in polynomial time, a General Factors instance (G,) with the following properties:

  1. (i)

    (D,cap,) has an integral -transshipment of value p if and only if (G,) has a factor of size 2p.

  2. (ii)

    Given a tree decomposition for the underlying undirected graph of D of width tw, we can compute a tree decomposition of width max{2,tw} for G in polynomial time.

  3. (iii)

    The max-gap of is max{1,γ}, where γ is the max-gap of .

Proof.

Let (D,cap,={BvvV(D)}) be a given 2GT instance with A(D)U×W. Now, consider the multigraph, which is obtained by replacing every arc (u,w) with cap(u,w) many undirected parallel edges between u and w. Moreover, set {abs(Bv)Bv}, where abs(Bv){|x|xBv}. We can transform the multigraph into a simple graph by subdividing every edge and adding the degree constraint {0,2} to for every newly created vertex. We refer to the set of new vertices by H and if necessary, we call the vertex, which was introduced for the ith parallel edge between u and w, by huwi. We call the obtained graph G and the constructed General Factors instance is (G,). We next show property (i).

”:

Let f be an integral -transshipment for (D,cap,). We show that there is a general factor FE(G) for the instance (G,) of size |F|=2val(f). Intuitively, if the flow value on the arc (u,w) is f(u,w), then we add 2f(u,w) edges from G to F, such that they correspond to f(u,w) copies of the edge {u,w}. Formally, we set

F:=(uw)A(D)i=1f(u,w){{u,huwi},{huwi,w}}.

Since every flow from U to W counts towards val(f), it directly follows that |F|=2val(f). It remains to show that F satisfies the degree constraints , that is, deg(V(G),F)(v)Bv for every vV(G). Recall, that for hH, we have Bh={0,2}. By construction, we either add zero or two edges incident to h to F and therefore we have deg(V(G),F)(h)Bh. For vUW, note that the degree in (V(G),F) coincides exactly with the absolute value of fΣ(v). This together with fΣ(v)Bv implies that deg(V(G),F)(v)abs(Bv).

”:

Now suppose FE(G) is a -factor. We show that there exists a -transshipment f with val(f)=|F|2. Let (u,w) be an arc in D. By construction, if {u,huwi}F for some huwiH, then also {huwi,w}F, because Bhuwi={0,2}. Now, we define a flow f by setting f(u,w) to the number of vertices from H to which both u and w are connected in (V(G),F). This is an integral feasible flow since for every arc (u,w)A(D) both u and w have by construction at most cap(u,w) common neighbors in G. Moreover, for each uU, we have fΣ(u)=deg(V(G),F)(u)abs(Bu)=Bu and for each wW, we have fΣ(w)=deg(V(G),F)(w){xxabs(Bw)}=Bw. Since exactly |F|2 edges are between U and H and also between H and W, it follows val(f)=|F|2.

It remains to show the two properties (ii) and (iii).

(ii):

Let (𝒯,(Xi)iV(𝒯)) be a tree-decomposition of width tw for the underlying undirected graph of D. For each arc (u,w)A(D), there exists a bag Xi with {u,w}Xi. We obtain a tree decomposition for G of width max{2,tw} by appending one bag {u,w,huwj} to Xi for each j[cap(u,w)].

(iii):

Note that, for any vertex hH, the set Bh has a gap of exactly one. For vUW, the collection contains the set abs(Bv) which has the same gap as Bv since either Bv0+ or Bv0.

To sum up, we have seen that a 2GT instance allowing flows in an interval with integer endpoints can be restricted to an integral instance and that integral 2GT instances can be translated into equivalent General Factors instances. For non-integral 2GT instances, the reduction to General Factors does not work. A common trick we will use later, is to scale capacities and excess constraints by some factor in order to make them integral. This scaling obviously influences the overall flow value.

Lemma 4.5.

Let (D,cap,) be a 2GT instance, q0+ and (D,cap,) be the instance, which is obtained by multiplying all excess constraints and capacities from (D,cap,) with q. Then, (D,cap,) has a maximum -transshipment value of p if and only if (D,cap,) has a maximum -transshipment value of pq.

Proof.

Clearly, since all capacities and excess values are multiplied by q, it follows that f is a maximum -transshipment if and only if f with f(u,w)qf(u,w) for all (u,w)A(D) is a maximum -transshipment.

We write q for to indicate that was obtained from by scaling with factor q.

4.3 Algorithmic Consequences

2-Layer General Transshipment.

Having discussed how to translate a 2GT instance into a General Factors instance, we now consider the algorithmic implications for the 2GT problem. We obtain three algorithmic results as stated in the following theorem.

Theorem 4.6.

Let (D,cap:A(D),) be an instance of 2GT.

  1. (i)

    If Bv=[av,bv] for each vertex v with av0bv and the excess constraints and capacities are polynomially bounded in the size of D, then one can compute in randomized O(m1+o(1)) time a maximum -transshipment.

  2. (ii)

    If Bv has gap at most one for each vertex v and capacities are bounded polynomially, then one can compute in polynomial time a maximum -transshipment or output that there exist no feasible flow.

  3. (iii)

    Suppose we are given a tree decomposition for the underlying undirected graph of D of width tw. Moreover, suppose that Bv for each vertex v and that capacities are bounded polynomially. Let MmaxvV(D)max{|x|xBv}. Then, one can compute in (M+1)tw+1nO(1) time a maximum -transshipment or output that there exists no feasible flow.

Proof.

We prove each of the three statements separately.

(i):

We provide a linear-time reduction to Maximum Flow. If the edge capacities are integers and polynomially bounded, then an (integral) maximum flow for this instance can be computed in randomized m1+o(1) time [7]. Now consider the following Maximum Flow instance, where we take the network D, add a source vertex s, a sink vertex t and the following arcs:

  • For every uU, we add the arc (s,u) with capacity bu.

  • For every wW, we add the arc (w,t) with capacity aw.

This network can be constructed in O(mD+nD)=O(mD) time. We now compute a maximum flow f for this network and obtain a -transshipment by setting f(u,w)f(u,w) for all (u,w)A(D). Note that f is feasible since fΣ(u)=fΣ+(u)[0,bu] for all uU and fΣ(w)=fΣ(w)[aw,0] for all wW. Furthermore, f is a maximum flow since val(f)=val(f) and any flow in the transshipment instance can be directly translated to an s-t-flow f of the same value as follows:

f(a){fΣ(u)if a=(s,u) for some uUf(a)if aA(D)fΣ(w)if a=(w,t) for some wW.
(ii):

We apply Lemma 4.4 and obtain a General Factors instance (G,) which has gap exactly one by Lemma 4.4 (iii). Using an algorithm from Dudycz and Paluch [10] we can now find a maximum -factor F of G in polynomial time. In particular, Lemma 4.4 gives us a -transshipment of value |F|2 and implies that this is indeed the maximum. On the other hand, if there is no solution to (G,), then there is also no feasible flow for (D,cap,).

(iii):

We again apply Lemma 4.4 and obtain a General Factors instance (G,). By Lemma 4.4 (ii), we get a tree decomposition for G of width at most tw+1 and, by construction of the General Factors instance, we know that max{maxBB}M (note that we can assume M2 since otherwise we are in case (ii) which is polynomial-time solvable). This allows us to apply a result from Marx et al. [17], which states that a maximum -factor of G can be computed in (M+1)tw+1nO(1) time. If there is no solution to (G,), then there is also no feasible flow for (D,cap,).

𝝉-Bounded-Density Edge Deletion.

In Section 4.1 we described how to reduce τ-BDED to 2GT. Therefore, the results from Theorem 4.6 for 2GT translate directly to τ-BDED and imply the algorithmic results in Theorems 1.1 and 1.2:

Theorem 4.7.

Let =(G,k) be a τ-Bounded-Density Edge Deletion instance.

  1. (i)

    If τ, then one can decide in randomized O(m1+o(1)) time.

  2. (ii)

    If 2τ, then one can decide in polynomial time.

  3. (iii)

    If τ=ab for some fixed a,b and a tree decomposition for G of width tw is given, then one can decide in (max{a,b}+1)tw+1nO(1) time.

Proof.

Recall the construction of a 2GT instance T()=(D,cap,) from Section 4.1, which has maximum -transshipment of value at least mGk if and only if (G,k,τ) is a yes-instance (see Lemma 4.1). The capacities on the arcs in D are one and the excess constraints are of the form {0,1} and [τ,0]. Since τ is bounded polynomially in nD, clearly so are all the capacities and excess constraints. This also holds when scaling the instance with a constant, as described in Lemma 4.5. Using the construction, we can derive the three statements.

(i):

First, note that T() can be constructed in O(mG+nG)=O(mG) time. The excess constraints are of the form {0,1} and [τ,0]. Since τ and a feasible solution exists (e.g. sending a flow of 0 along all arcs), we can apply Lemma 4.2 which guarantees us the existence of an integral maximum -transshipment. Subsequently, ˜4.3 tells us that we can restrict all the excess constraints to their intersection with . This allows us to apply Theorem 4.6 (i), which concludes the algorithm.

(ii):

By Lemma 4.5, we can scale the 2GT instance T() by the factor two and the obtained excess constraints are of the form {0,2} and [2τ,0]. Since 2τ is integer and a feasible solution exists, we can again apply Lemma 4.2 which gives us the existence of an integral maximum flow. Again, ˜4.3 tells us that we can restrict all the excess constraints to their intersection with . Note that the excess constraints are now of the form {0,2} and [2τ,0]. In particular, they have gap at most one and therefore the obtained transshipment instance satisfies the conditions of Theorem 4.6 (ii). Since we scaled T() by two, the maximum 2-transshipment value is at least 2(mGk) if and only if (G,k,τ) is a yes-instance.

(iii):

By Lemma 4.5, we can scale the 2GT instance T() by the factor b and the obtained excess constraints are of the form {0,b} and [bτ,0]=[a,0]. This scaled version has a maximum b-transshipment of value at least b(mGk) if and only if the original instance has a maximum flow of at least mGk. By the same arguments as above, we can restrict the excess constraints to their intersections with . Furthermore, we easily obtain a tree decomposition for the underlying undirected graph of D of width tw since the graph can be obtained by subdividing all edges of G [9]. To finish the proof, note that we can now apply Theorem 4.6 (iii) to compute a maximum transshipment in (max{a,b}+1)tw+1nO(1) time. We then return yes if and only if the value is at least b(mGk).

5 NP-hardness Results

In this section, we complement our algorithmic findings from Section 4 by showing NP-hardness for every constant target density τ{qq2/3q}, thereby completing the proof of Theorem 1.1. We prove the result in two steps. First, we show that any fixed target density τ[2/3,1) yields NP-hardness. Afterwards, we show that τ-BDED is NP-hard for any constant target density τ{qq>1q}.

Case 𝝉<𝟏.

Note that for τ<1 any solution graph (the graph obtained by removing at most k edges) cannot contain a cycle as a cycle has density 1. Hence, any solution graph is a forest. The maximum density of a forest is determined by the size of a largest tree in it as a tree with n nodes has n1 edges and thus density 11/n, which is monotonically increasing for increasing values of n. Thus, any target density τ<1 can be replaced by the largest value ττ with τ=/+1 for some . For =0, we have to remove all edges and thus τ-BDED becomes trivial. For =1, the problem is equivalent to finding a smallest set of edges that only leaves a matching. This can be solved in polynomial time by computing a maximum matching and returning all non-matching edges. For {2,3}, Bazgan et al. [3] showed NP-hardness. We extend their hardness result for =3 to arbitrary . The proof consists of a reduction from Exact Cover By -Sets (XC) and is sketched in Figure 2.

Figure 2: A schematic illustration of the reduction in Theorem 5.1. Given an instance of XC with universe X={x1,x2,,xq} and set collection C={C1,C2,,Ct}, we add a vertex yi for each element xiX and a vertex cj for each set CjC. We add an edge {yi,cj} whenever xiCj. We further add dummy stars with 1 leaves and fully connect their centers to the vertices representing C. Any τ-BDED solution then leaves t stars with leaves and there is a a one-to-one mapping between (green) star centers and sets selected in an XC solution.
Theorem 5.1.

τ-BDED is NP-hard for any τ=/+1 with 3.

Proof.

We reduce from Exact Cover By -Sets, which is NP-hard for 3 [13]. It is defined as follows.

Exact Cover By -Sets (XC)
Input: A set X with |X|=q and a collection C of -element subsets of X.
Question: Is there a subcollection C of C where every element of X occurs in exactly one set in C?

The proof is a straightforward adaption of the hardness proof for τ=3/4 [3]; see Figure 2 for a sketch. Let (X,C) be an instance of XC with X={x1,x2,,xq} and C={C1,C2,,Ct}. If t<q, then we trivially have a no-instance as not all elements appear in a set in C. So we assume tq and construct a graph G as follows: We start with one vertex yi for each element xiX and one vertex cj for each set CjC. We add an edge {yi,cj} whenever xiCj. We then add a set of tq stars S1,S2,,Stq each with 1 leaves to G. Formally, for each i[tq], we add a vertex ui and for each i[tq] and each j[1], we add a vertex zij and the edge {ui,zij}. Next, we add all edges {cj,ui} with j[t] and i[tq]. This concludes the construction of G. Let m be the number of edges in it. To conclude the entire construction, we set kmt.

Since the construction takes polynomial time, it only remains to show correctness. To this end, first assume that there is a solution C for the input instance (X,C) of XC. Note that |C|=q. We construct a set B of t edges such that deleting all edges except for those in B is a solution for the constructed instance of τ-BDED. For each CjC, include the edges joining cj to vertices yi with xiCj. Note that there are exactly q such edges. Moreover, for each i[tq] and each j[1], we add the edge {ui,zij} to B. Finally, for each CjC, we pick a distinct vertex ui and include {ui,cj} in B. Note that there are exactly tq sets in CC and also tq vertices ui. Therefore, B contains a perfect matching between these two sets of vertices. Overall, B has size q+(1)(tq)+(tq)=t. Note that each vertex cj belongs to a different connected component in the graph induced by B. Moreover, each such vertex belongs to a tree with additional vertices (either a star Sj or y-vertices). Thus, the maximum density is /+1, concluding the first part of the proof.

For the other direction, assume that there is a set F of at most k edges whose removal yields a graph with maximum density at most τ=/+1. Note that the constructed graph G has (+1)t vertices. Moreover, GF has at least m|F|mk=t edges. Since any cycle has density 1, GF is a forest and since any tree with +2 vertices has +1 edges and therefore density +1/+2>/+1, it holds that each tree in GF contains at most +1 vertices. If GF contains exactly t trees, each with +1 vertices and edges, then GF contains t edges and F contains mt=k edges. Since G is connected (assuming each element appears in at least one set in C), increasing the number of trees in GF or decreasing the size of any tree in GF increases the size of F to above k. Thus, GF contains exactly t trees and each tree contains +1 vertices and edges. This implies that no edge {ui,zij} for any i[tq] and any j[1] is contained in F. Moreover, each vertex uj is adjacent to exactly vertices in GF and thus exactly one edge {ui,cj} is not contained in F for each i[tq] (and the index j is unique for each i). Consider the remaining q vertices cj that are not connected to a star Si. We claim that the corresponding sets Cj are a solution for the original instance of XC. Consider an arbitrary vertex yi (corresponding to an element xiX). By construction, yi is only adjacent to vertices cj with xiCj. Since each tree in GF contains exactly +1 vertices and only q vertices cj and q vertices yi are not yet distributed, each such undistributed vertex cj must be adjacent to vertices yi each and each vertex yi is only adjacent to a single vertex cj in GF. Note that this exactly corresponds to an exact cover, concluding the proof.

Case 𝝉>𝟏.

Our goal is to show that τ-BDED is NP-hard for any constant τ=p/q>1 with τ. The proof will be a reduction from Vertex Cover on q-regular graphs which mostly consists of two types of gadgets: vertex gadgets and edge gadgets. On a high level, the vertex gadgets are balanced graphs with density τ. The edge gadgets have density slightly below τ, but there are also two edges connecting each edge gadget to the two corresponding vertex gadgets. Combined, an edge gadget and the two corresponding vertex gadgets have density slightly larger than τ (in such a way that (m1/q)/n=τ). The idea is that deleting one edge in a vertex gadget is sufficient to “fix” all adjacent edge gadgets.

The vertex gadget will be based on the following lemma. We state it in a more general form which can be applied whenever a solution graph contains a cycle. It states that in a cycle, we can always assume that at least one edge in a fractional orientation is fully assigned to one of its endpoints. The idea is to simply shift the fractional orientation around the cycle until this is no longer possible in which case one of the edges fully assigns its fractional orientation to one endpoint.

Lemma 5.2.

Let G be a graph containing a cycle C and let ϕ be a fractional orientation of G. Then, there exists a fractional orientation ϕ with degϕ(v)=degϕ(v) for all vV(G) and an edge e={u,v} in C with ϕ(e)u=1, that is, e is completely assigned to one of its endpoints by the fractional orientation ϕ. Given G, C, and ϕ, then ϕ can be found in linear time with respect to the size of G.

Proof.

Let C=(v1,,v,v+1=v1). If there already exists an edge {vi,vi+1} in C with ϕ(vivi+1)vi=1 or ϕ(vivi+1)vi+1=1, then we are done. Otherwise, let εi:=ϕ(vivi+1)vi for each i[], ε:=mini[]εi and let j be an index such that ε=εj. We obtain the desired fractional orientation ϕ from ϕ by setting ϕ(e)=ϕ(e) for all edges in G that are not {vi,vi+1} for some i[], ϕ(vivi+1)vi+1ϕ(vivi+1)vi+1+ε and ϕ(vivi+1)vi=ϕ(vivi+1)viε for all i[]. Note that this is possible by the definition of ε and ϕ(vjvj+1)vj+1=1. Moreover, degϕ(v)=degϕ(v) for all vV(G). Given G, C and ϕ, clearly ϕ can be determined in linear time with respect to the size of G considering edges in the cycle at most twice and all other edges at most once.

For the edge gadget, the basic idea is to start with a path adding additional edges in regular intervals to construct a near balanced graph with two orientations such that all vertices except for the two endpoints of the path have indegree τ and one endpoint has indegree τ1 and the other has indegree τ1+1/q. Connecting each endpoint of the path via a single edge with the corresponding vertex gadget then ensures that at least one edge in one of the three gadgets has to be deleted. Recall that we want to encode that a vertex is part of a vertex cover if an edge is removed in the corresponding vertex gadget. The excess value of 1/q will be small enough to distribute the available capacity generated by a single edge deletion to all incident edge gadgets.

Lemma 5.3.

For every constant rational number τ=pq>1, where p and q are coprime, a graph W with two special vertices u and w can be constructed in constant time, such that there exist two fractional orientations ϕ1 and ϕ2 with the following properties:

  1. (i)

    degϕ1(v)=degϕ2(v)=τ for all vV(W){u,w},

  2. (ii)

    degϕ1(u)=degϕ2(w)=τ1+1q and

  3. (iii)

    degϕ1(w)=degϕ2(u)=τ1.

Proof.

Let p=cq+r where c and r are integers and 0r<q. Note that r1 since p and q are coprime and c1 since τ>1. Let pp(c1)q=q+r, and τp/q. Note that 1<τ<2 and that p and q are coprime. We construct the graph W in two stages. First, we construct a graph W for target density τ and then we use this construction to construct the graph W for target density τ.

Note that if the graph W has n vertices and fulfills the requirements for the fractional orientations (for the target density τ), then the number m of edges in it fulfills m=τn2+1q. This number is not necessarily an integer, but since p and q are coprime, we can choose n such that (pn)modq=q1 (see for example Burton [4] for more details). Then, m=τn2+1q=pn+12qq is an integer. Moreover, we can increase n by aq for any positive integer a and this increases m by ap and thus m remains an integer. Since 2q>p>q as 1<τ<2, this allows us to pick222Use the extended Euclidean algorithm to first get an integer t, such that 1tpmodq. Setting n=((q1)t)modq satisfies (np)modq=((q1)tp)modq=q1. Let m=pqn2+1q. If n+1m (implying n4¸), set n=n, m=m, otherwise iteratively increment n by q until the condition holds. Since every increase of n by q increases m by p with p<q and since initially n<q, this procedure terminates after at most q steps. a positive integer n4 such that m is also a positive integer with n+1m2n3.

To construct W with n vertices and m edges, we start with a path (u=v1,,vn=w) and iteratively add edges to the construction while simultaneously ensuring the existence of the desired fractional orientation ϕ1. We will later show how to modify ϕ1 to get ϕ2. First, we orient the edge {u,v2} with a value of τ1+1/q to u and with a value of 1(τ1+1/q)=2p1q to v2. This is possible since 1τ=pq<p+1q2. Now starting from i=2 and for increasing values, we orient the edge {vi,vi+1} in such a way, that vi gets indegree exactly τ from the already oriented edges until we reach a point where even assigning a value of 1 is not enough. In the latter case, we add the edge {vi,w} to the graph and orient it completely to vi. We then continue with the edge {vi,vi+1} as before but now, whenever a value of 1 is not enough, we add the edge {u,vi} and completely orient it towards vi. See Figure 3 for an illustration.

Figure 3: Illustration of the edge gadget described in Lemma 5.3 with fractional orientation ϕ1 on the top and ϕ2 on the bottom. Vertices {u=v1,,vj,,vn=w} form a path to which edges are added to ensure an indegree of τ w.r.t. ϕ1 for all vertices except u and w (which have an indegree of τ1+1q and τ1 respectively). Vertex vj is the first vertex which requires an additional edge to reach τ and x is the amount of fractional orientation it receives from vj1. To create ϕ2 from ϕ1, fractional orientation is “pushed” from u to w, flipping their indegrees.

Note that since mn+1 (we will next show that the constructed graph has exactly m edges) and n1 edges belong to the initial path P, we add at least two edges in that way and hence the edges we try to add are not part of the path already (and we never try to add two edges to the same vertex as τ<2). Moreover, since m2n3 and n1 edges belong to the initial path, we only add at most n2 edges and hence there are enough vertices to add sufficiently many edges. We next show that after doing the above for all 2in1, the graph contains exactly m edges and ϕ1 fulfills all requirements from the lemma statement (for target density τ). By construction, the indegree of u with respect to ϕ1 is τ1+1q and the indegree of each vertex vi with 2in1 is τ. Added over all vertices, the sum of in-degrees is (n1)τ1+1q. The indegree of w is some value t between 0 and 1 (only the edge {vn1,w} assigns some positive value to w). Since the sum of indegrees equals the number of edges, it holds that (n1)τ1+1/q+t. Note that this is the case for t=τ1 since then, (n1)τ1+1/q+t=nτ2+1/q=pn+1q2, which is an integer by the choice of n. Moreover, t=τ1 is the only value between 0 and 1 for which this is the case as increasing/decreasing the number of edges by one also increases or decreases t by 1. Hence, the number of edges in the constructed graph is nτ2+1/q=m, and t=τ1. Thus, the orientation ϕ1 fulfills all requirements of the lemma statement.

It remains to show the existence of the fractional orientation ϕ2 and to adapt the construction for target densities larger than 2. Towards the former, let j be the index where we added the edge {vj,w}. Note that this index exists as mn. Intuitively, we modify ϕ1 by sending an orientation value of 1/q from u to w along the path (u,v2,,vj,w). Note that by construction all orientations in ϕ1 are multiples of 1/q. To construct ϕ2 from ϕ1 more formally, we set (for all i[2,j1])

ϕ2(uv2)u ϕ1(uv2)u1q, ϕ2(uv2)v2 ϕ1(uv2)v2+1q,
ϕ2(vivi+1)vi ϕ1(vivi+1)vi1q, ϕ2(vivi+1)vi+1 ϕ1(vivi+1)vi+1+1q,
ϕ2(vjw)vj ϕ1(vjw)vj1q, and ϕ2(vjw)w ϕ1(vjw)w+1q.

Note that if none of the above edges assign a value of 1 to the “later” vertex (the one with higher index), then the above modification is possible and ϕ2 also fulfills all requirements from the lemma statement. Assume towards a contradiction that some edge {vi,vi} assigns a value of 1 to the later vertex. Let i<i without loss of generality and note that by construction in as the edge {vj,w} is fully assigned to vj and i1 as τ>1 (and hence u is assigned a positive value τ1+1/q>1/q). Hence, i=i+1 and i<j. This implies that vi is assigned a value of at most 1<τ by ϕ1 as it is only incident to {vi1,vi} and {vi,vi+1} as i<j and j is the first index where we added an additional edge. Thus, the assumption that {vi,vi} is fully oriented towards vi leads to a contradiction. This shows that the above modification is possible and ϕ2 exists as claimed.

Finally, we adapt the construction to increase the density from τ=(q+r)/q by c1 to (q+r)/q+c1=(cq+r)/q=p/q=τ. To this end, we add a balanced graph A with density τ (which always exists and Ruciński and Vince [20] show how to construct such a graph for each τ1). Note that since any graph with n vertices has density at most (n2)/n=(n1)/2<n, it holds that A contains at least c1 vertices (but the size of A is constant for each constant τ). We select a set D of c1 arbitrary vertices in A. To conclude the construction of the edge gadget, we add an edge between each vertex in W and each vertex in D. To construct the orientations ϕ1 and ϕ2 for target density τ, we start with an orientation for A where each vertex is assigned exactly τ. Note that this exists as A is balanced and has density τ. For the edges in W, we use the orientations ϕ1 for ϕ1 and ϕ2 for ϕ2, respectively. Finally, we orient all edges between W and D completely towards the vertices in W. It is now easy to verify that all requirements of the lemma are satisfied by ϕ1 and ϕ2. Clearly if p and q are constant, the construction takes constant time. We are now ready to prove the main result of this section. This will conclude the proof of Theorem 1.1, which then follows from Theorem 4.7 (for the algorithmic part) and Theorems 5.1 and 5.4 (for the NP-hardness).

Theorem 5.4.

τ-BDED is NP-hard for any τ>1 with τ.

Proof.

Let τ=p/q>1 where p and q are coprime. Note that since τ, it holds that q3. We give a reduction from Vertex Cover on q-regular graphs. It is folklore knowledge that this problem is NP-complete.333Amiri [2] showed that the problem cannot be solved in 2o(m) time unless the ETH fails. The same reduction also shows NP-hardness, but this is not explicitly mentioned. The idea is to construct a vertex gadget for each vertex and an edge gadget for each edge in G using Lemmas 5.2 and 5.3, respectively.

Let (G=(V,E),k) be an instance of Vertex Cover where G is q-regular. We construct an equivalent instance (G,k) of τ-BDED as follows. For each vertex vV, we add a vertex gadget Hv with a special edge ev and an incident vertex xv to G. The graph Hv is any balanced graph with density τ (which always exists and Ruciński and Vince [20] show how to construct such a graph for each τ1). Let ϕv be any fractional orientation for Hv where each vertex has indegree τ and let C be any cycle in Hv. Both can be found in polynomial time. Using Lemma 5.2, we construct another fractional orientation ϕv where each vertex has indegree τ and one edge e fully assigns its orientation to one of its endpoints u. We set eve and xvu. This concludes the construction of the vertex gadget. For each edge e={u,v}E, we add the edge gadget We, which is the graph obtained from the construction in Lemma 5.3 for density τ with special vertices wu and wv. We connect the gadgets by adding the edges {xu,wu} and {xv,wv} to our construction. Note that we can use Lemma 5.3 since we assumed that p and q are coprime. To conclude the construction, we set kk. A visualization of the reduction is shown in Figure 4.

Figure 4: Illustration of the hardness reduction for τ=p/q>1. Depicted is the construction for two vertices u,v in the Vertex Cover instance connected by an edge e={u,v} with τ=75. To the left and right are vertex gadgets Hu and Hv (highlighted in green) with special vertices xu and xv and the special edges eu and ev oriented fully towards xu and xv respectively (indicated with the thickening edge). The vertex gadgets are connected by the edge gadget We with special vertices wu and wv. Light red lines indicate edges from xu and xv to other edge gadgets. Note that for τ=75, a balanced graph on 5 vertices with 7 edges can be created using the construction of Ruciński and Vince [20]. For p>(q2), observe that a graph on pq vertices and p2 edges (of density τ=p/q) can be created.

Since the reduction can be computed in polynomial time as the graphs Hv and We have constant size, it only remains to show correctness. To this end, first assume that (G,k) is a yes-instance of Vertex Cover and let C be a vertex cover of size at most k in G. For each vC, we add the edge ev in the vertex gadget Hv to the solution set F. Note that these are |C|k=k edges. By Lemma 2.1, it suffices to provide a fractional orientation ϕ of GF with Δϕτ, which we construct as follows. We use the fractional orientation ϕv for each vertex gadget (with potentially the edge ev removed). Hence, the indegree of each vertex in a vertex gadget is τ unless it is the vertex xv in a vertex gadget corresponding to a vertex vC. In this case, the indegree is τ1. We next construct the fractional orientation for each edge gadget We for an edge e={u,v} (including the two edges connecting it to vertex gadgets). We assume without loss of generality that uC (if both are contained, we pick one endpoint arbitrarily; the case where only v is part of the vertex cover is analogous). This means that the vertex xu has indegree τ1 in the current orientation. We use Lemma 5.3 to obtain a fractional orientation of the edges in We such that now all vertices in it except for wu and wv have indegree τ and wu has indegree τ1+1/q and wv has indegree τ1. We orient the edge {wv,xv} completely towards wv and the edge {wu,xu} with a value of 11/q to wu and with a value of 1/q to xu. By doing this for every edge e, we obtain a fractional orientation ϕ of GF where each vertex has indegree at most τ since each vertex xu is only connected to at most q edge gadgets that assign an orientation of 1/q each.

Conversely, assume that the constructed instance of τ-BDED is a yes-instance and let F be a solution of size at most k=k. We construct a vertex cover C of size at most k for G as follows. For all edges eF which are contained in some vertex gadget Hv or connect a vertex in Hv with an edge gadget, we add v to the vertex cover C. If eF is contained in an edge gadget We, then we arbitrarily pick one of the two endpoints of e and add it to C. Since we selected at most k vertices, it only remains to prove that C is a vertex cover. Assume towards a contradiction that this is not the case. Then, there exists some edge e={u,v} where u,vC. Note that this implies that no edge incident to a vertex in the vertex gadgets corresponding to u and v and no edge in the edge gadget corresponding to e are contained in F. Let nv be the number of vertices in a vertex gadget and let ne be the number of vertices in an edge gadget. The union of the three aforementioned gadgets (plus the two edges between the gadgets) contains 2nv+ne vertices and τ(2nv)+(τne2+1/q)+2=τ(2nv+ne)+1/q>τ(2nv+ne) edges. Hence, the density of this subgraph is larger than τ, contradicting the fact that F is a solution. This concludes the proof.

6 Conclusion

We provided a complexity dichotomy of τ-BDED with respect to the target density τ by showing that the problem is polynomial-time solvable if and only if τ is half-integral or smaller than 2/3 (assuming PNP). We also observed an encouraging result regarding the treewidth of the input graph. Studying τ-BDED with respect to further natural parameters like clique-width, or the diameter of the input graph and/or from the viewpoint of approximation algorithms are natural next steps. Another next step is to analyze cases in which τ is not constant but can depend on e.g. n. Our polynomial-time algorithms for (half-)integral target densities generalize to this setting. However, our hardness results and the FPT algorithm for treewidth do not. It is known that for some value τ=11/o(n) depending on n the problem becomes W[1]-hard with respect to the treewidth [3] and it is polynomial-time solvable for τ=11/n since this is equivalent to computing a feedback edge set of the input graph. Another generalization our polynomial-time algorithms cover are weighted problem variants of τ-BDED as the weighted variants of Maximum s-t-Flow (Flow) and General Factors (GF) are polynomial-time solvable [10, 21].

Concerning 2GT, an interesting question is whether the efficiently solvable cases discovered in this work (max-gap at most one, bounded treewidth) can be extended to cover larger classes of networks. For example, the NP-hardness for the case that only some arcs have an even flow restriction requires to “stack” several of them on paths: Each path from s to t in the constructed acyclic flow instance contains exactly three arcs requiring even flow (see full version of the paper). Hence, the question arises if the problem is polynomial-time solvable if each such restricted arc is incident to s or t.

References

  • [1] Ravindra K. Ahuja, Thomas L. Magnanti, and James B. Orlin. Network flows – Theory, algorithms and applications. Prentice Hall, 1993.
  • [2] Saeed Akhoondian Amiri. A note on the fine-grained complexity of MIS on regular graphs. Information Processing Letters, 170:106123, 2021. doi:10.1016/J.IPL.2021.106123.
  • [3] Cristina Bazgan, André Nichterlein, and Sofia Vazquez Alferez. Destroying densest subgraphs is hard. Journal of Computer and System Sciences, 151:103635, 2025. doi:10.1016/j.jcss.2025.103635.
  • [4] David M. Burton. Elementary Number Theory. Tata McGraw-Hill Publishing Company Limited, 2006.
  • [5] Karthekeyan Chandrasekaran, Chandra Chekuri, and Shubhang Kulkarni. On deleting vertices to reduce density in graphs and supermodular functions. In Proceedings of the 52nd International Colloquium on Automata, Languages, and Programming (ICALP), pages 43:1–43:20. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2025. doi:10.4230/LIPIcs.ICALP.2025.43.
  • [6] Moses Charikar. Greedy approximation algorithms for finding dense components in a graph. In Proceedings of the 3rd International Workshop on Approximation Algorithms for Combinatorial Optimization (APPROX), pages 84–95. Springer, 2000. doi:10.1007/3-540-44436-X_10.
  • [7] Li Chen, Rasmus Kyng, Yang P. Liu, Richard Peng, Maximilian Probst Gutenberg, and Sushant Sachdeva. Almost-linear-time algorithms for maximum flow and minimum-cost flow. Communications of the ACM, 66(12):85–92, 2023. doi:10.1145/3610940.
  • [8] Gérard Cornuéjols. General factors of graphs. Journal of Combinatorial Theory, 45(2):185–198, 1988. doi:10.1016/0095-8956(88)90068-8.
  • [9] Marek Cygan, Fedor V. Fomin, Lukasz Kowalik, Daniel Lokshtanov, Dániel Marx, Marcin Pilipczuk, Michal Pilipczuk, and Saket Saurabh. Parameterized Algorithms. Springer, 2015. doi:10.1007/978-3-319-21275-3.
  • [10] Szymon Dudycz and Katarzyna Paluch. Optimal general matchings. In Proceedings of the 44th International Workshop on Graph-Theoretic Concepts in Computer Science (WG), pages 176–189. Springer, 2018. doi:10.1007/978-3-030-00256-5_15.
  • [11] Michael R. Garey and David S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, 1979.
  • [12] Andrew V. Goldberg. Finding a maximum density subgraph. Technical report, University of California at Berkeley, USA, 1984.
  • [13] David G. Kirkpatrick and Pavol Hell. On the completeness of a generalized matching problem. In Proceedings of the 10th Annual ACM Symposium on Theory of Computing (STOC), pages 240–245. ACM, 1978. doi:10.1145/800133.804353.
  • [14] Tuukka Korhonen. A single-exponential time 2-approximation algorithm for treewidth. In Proceedings of the 62nd IEEE Annual Symposium on Foundations of Computer Science (FOCS), pages 184–192, 2021. doi:10.1109/FOCS52979.2021.00026.
  • [15] Tuukka Korhonen and Daniel Lokshtanov. An improved parameterized algorithm for treewidth. In Proceedings of the 55th Annual ACM Symposium on Theory of Computing (STOC), pages 528–541, 2023. doi:10.1145/3564246.3585245.
  • [16] Tommaso Lanciano, Atsushi Miyauchi, Adriano Fazzone, and Francesco Bonchi. A survey on the densest subgraph problem and its variants. ACM Computing Surveys, 56(8):208:1–208:40, 2024. doi:10.1145/3653298.
  • [17] Dániel Marx, Govind S. Sankar, and Philipp Schepper. Degrees and gaps: Tight complexity results of general factor problems parameterized by treewidth and cutwidth. In Proceedings of the 48th International Colloquium on Automata, Languages, and Programming (ICALP), pages 95:1–95:20. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.ICALP.2021.95.
  • [18] Luke Mathieson and Stefan Szeider. Editing graphs to satisfy degree constraints: A parameterized approach. Journal of Computer and System Sciences, 78(1):179–191, 2012. doi:10.1016/J.JCSS.2011.02.001.
  • [19] Jean-Claude Picard and Maurice Queyranne. A network flow solution to some nonlinear 0-1 programming problems, with applications to graph theory. Networks, 12(2):141–159, 1982. doi:10.1002/NET.3230120206.
  • [20] Andrzej Ruciński and Andrew Vince. Strongly balanced graphs and random graphs. Journal of Graph Theory, 10(2):251–264, 1986. doi:10.1002/jgt.3190100214.
  • [21] Alexander Schrijver. Combinatorial optimization: Polyhedra and efficiency. Springer, 2003.