Similar to the algorithm by Lenstra
et al. [
2], our approximation algorithm uses an estimation
T of the maximum load of a vertex in an optimal orientation as a parameter. The algorithm GB2W presented below as Algorithm 1 finds a solution of value at most
$3T/2$ if a solution of value at most
T exists. We combine this algorithm with a binary search procedure to find the smallest value for
T for which an orientation with load at most
$3T/2$ for the graph balancing problem with two weights is found: if for a given
T the algorithm does not find a solution of value at most
$3T/2$ then the value of
T is increased in the binary search; otherwise it is decreased. By the above property of our algorithm this smallest value of
T must be less than or equal to the value of an optimum solution, hence our algorithm has approximation ratio
$3/2$.
The remainder of this section gives Lemmas 1–4 which provide the subroutines used by our algorithm, then in Theorem 5 we prove our algorithm is a $3/2$approximation algorithm for GBP2W. First, we present Lemma 1 which covers Step 4 of our algorithm. Note that in Step 1 the algorithm scales the weights so the estimation for the optimum load is $T=1$. We define a big edge e to be an edge with weight ${p}_{e}>1/2$; otherwise, we call an edge small. Let the value for an optimum solution for the problem be denoted as $OPT$. From this point forward, we assume that as edges are oriented in Steps 4–5.3, they are removed from G.
2.2. Step 5.1
Next, we consider the case handled in Step 5.1 of the algorithm, namely when
$k/(k+1)\le s\le 1$ and
$k=\lfloor 1/r\rfloor $ so
$1/(k+1)<r\le 1/k$. In Lemma 2, we utilize the property that
$r+s>1$, which means that if
$OPT\le 1$, then no small edge can be oriented with a big edge towards a given vertex without causing the maximal load to be greater than 1.
Lemma 2. For any $k\ge 2$, there is a polynomialtime algorithm for the graph balancing problem with two rational weights $r,s$, where $1/(k+1)<r\le 1/k$ and $k/(k+1)\le s\le 1$ that either finds a solution of value at most $3/2$ or proves that $OPT>1$.
Proof. If
$OPT\le 1$, since
$r+s>1$, for any optimal orientation either at most a big edge is oriented towards a vertex, or at most
k small edges are oriented towards a vertex. This property is natural to encode into a flow network. To find an orientation for the edges of the weighted multigraph
$G=(V,E,\mathbf{p},\mathbf{q})$, we use a multilevel flow network similar to that in [
9].
We build a flow network
N as follows. First, we consider the dedicated loads of the vertices. For each vertex
$v\in V$, define a value
${\beta}_{v}\ge 0$ as follows: if
${q}_{v}\ge s$, set
${\beta}_{v}=k$; otherwise there is a nonnegative integer
${p}_{v}$ so that
${q}_{v}={p}_{v}r$, assign
${\beta}_{v}={p}_{v}$. The flow network will have a source
${\alpha}_{1}$ and sink
${\alpha}_{2}$. We will describe the network level by level. First, we have a level of nodes in the network called
edge nodes. These are nodes corresponding to the edges in the multigraph. There are two types of edge nodes: big edge nodes for edges with weight
s; and small edge nodes for those with weight
r. From source
${\alpha}_{1}$, add an arc from
${\alpha}_{1}$ to each edge node, and set its capacity to
k if it is to a big edge node, and 1 otherwise. The next level consists of
buffer nodes, one for each vertex. The buffer nodes are added to prevent excess flow from being contributed by the big edge nodes. While this part of the network is not important for proving this lemma, it will be vital for how we later use this network in Lemma 3. For each big edge
$\{u,v\}\in E$, add arcs with capacity
k from its big edge node to buffer nodes
u and
v. For the next level of the network, create a
vertex node that will correspond to each vertex in the multigraph. For each buffer node for
$v\in V$, add an arc from its buffer node to its vertex node with capacity
k. Next, for each small edge
$\{u,v\}\in E$, include arcs with capacity 1 from its small edge node to vertex nodes
u and
v. Finally, for each vertex
$v\in V$, add an arc from vertex node
v to sink
${\alpha}_{2}$ with capacity
$k{\beta}_{v}$. The resulting flow network is shown in
Figure 1.
Before we proceed to describe the algorithm, we show that this network has the following property: if
$OPT\le 1$, an integral maximum flow on this network saturates all the arcs leaving source
${\alpha}_{1}$. Consider any optimal orientation
${\gamma}^{*}$. Using
${\gamma}^{*}$ we construct a flow function in which every small edge node receives 1 unit of flow, and each big edge node receives
k units of flow from the source
${\alpha}_{1}$. For each big edge
$\{{u}_{1},{u}_{2}\}$ of
G with
${\gamma}^{*}({u}_{1},{u}_{2})={u}_{i}$, if
u is the big edge node for
$\{{u}_{1},{u}_{2}\}$ send
k units of flow from
${\alpha}_{1}$ to
u,
k units of flow from
u to buffer node
${u}_{i}$,
k units of flow from buffer node
${u}_{i}$ to vertex node
${u}_{i}$, and
k units of flow from
${u}_{i}$ to the sink
${\alpha}_{2}$. Similarly, for each edge
$\{{u}_{1},{u}_{2}\}$ represented by small edge node
u and
${\gamma}^{*}({u}_{1},{u}_{2})={u}_{i}$, send 1 unit of flow from
${\alpha}_{1}$ to
u, from
u to vertex node
${u}_{i}$, and from
${u}_{i}$ to
${\alpha}_{2}$. It is not hard to see that this flow function is feasible and that no additional flow can be sent through the network.
Algorithm 3: BigSmall_rs $(G=(V,E,\mathbf{p},\mathbf{q}))$ 
 Input:
Multigraph G. Note that $k=\lfloor 1/r\rfloor $.  Output:
An orientation γ for the edges in E with maximum vertex load at most $3/2$ or FAIL. If FAIL is returned there is no orientation for E with maximum vertex load 1.
Build the flow network N. Compute an integral maximum flow f of N. If all the arcs leaving the source are not saturated in f, then return FAIL. Construct bipartite graph ${G}^{\prime}=({V}_{big}\cup {V}_{rec},{E}^{\prime})$, where ${V}_{big}$ is the set of big edge nodes, ${V}_{rec}$ is the set of buffer nodes that receive at least $\lceil k/2\rceil $ units of flow from a big edge node, and
Compute a matching on ${G}^{\prime}$ that matches each node in ${V}_{big}$ with a unique vertex in ${V}_{rec}$. For each arc $(u,{u}_{i})$ in the matching of Step 5, orient big edge u towards vertex ${u}_{i}$. For each small edge node u and vertex node ${u}_{i}$ with $f(u,{u}_{i})=1$, orient u towards ${u}_{i}$. Return orientation for the edges of G.

The time complexity of algorithm BigSmall_
$rs$ (Algorithm 3) is polynomial. Now we prove that this algorithm finds an orientation with maximal load at most
$3/2$ if
$OPT\le 1$. If
$OPT\le 1$, then as shown above, every small edge node receives 1 unit of flow from
${\alpha}_{1}$. By flow conservation, each small edge node
u sends its one unit of flow to a vertex node
${u}_{i}$, and the algorithm orients small edge
u towards vertex
${u}_{i}$. As a result, every small edge is oriented by the algorithm. What remains to be shown is that all the big edges are oriented. The orientation of each big edge is determined by the matching computed by the algorithm. We must show this matching exists. Consider any subset
${V}_{big}^{\prime}\subseteq {V}_{big}$, and denote the neighbourhood in
${G}^{\prime}$ of this subset of nodes as
${N}_{{G}^{\prime}}({V}_{big}^{\prime})$. Note that
${N}_{{G}^{\prime}}({V}_{big}^{\prime})\subseteq {V}_{rec}$. To show the above matching exists, we prove
${V}_{big}^{\prime}\le {N}_{{G}^{\prime}}({V}_{big}^{\prime})$. Two key observations are that the outdegree of every edge node is 2, and every big edge node is sent at most
k units of flow. Furthermore, by flow conservation every big edge node must send at most
k units of flow to the buffer nodes. We have two cases:
If k is odd, a buffer node in ${N}_{{G}^{\prime}}({V}_{big}^{\prime})$ can receive at least $\lceil k/2\rceil $ units of flow from only one big edge node in ${V}_{big}^{\prime}$ because $k<2\xb7\lceil k/2\rceil $. Furthermore, since $k\lceil k/2\rceil =\lfloor k/2\rfloor <\lceil k/2\rceil $, each big edge node in ${G}^{\prime}$ has degree 1. Hence, ${V}_{big}^{\prime}={N}_{{G}^{\prime}}({V}_{big}^{\prime})$.
If k is even, $\lceil k/2\rceil =k/2$, and a buffer node can receive $k/2$ units of flow from at most two big edge nodes. Partition ${N}_{{G}^{\prime}}({V}_{big}^{\prime})$ into two disjoint sets ${N}_{1}$ and ${N}_{2}$, where ${N}_{1}$ contains the buffer nodes that receive more than $k/2$ units of flow from a big edge node, and ${N}_{2}$ has the buffer nodes that receive $k/2$ units of flow from a big edge node. Similar to when k is odd, each big edge node in ${V}_{big}^{\prime}$ is adjacent to only one buffer node in ${N}_{1}$, and so each buffer node in ${N}_{1}$ has degree 1 in ${G}^{\prime}$. This leaves ${V}_{big}^{\prime}{N}_{1}$ vertices adjacent to buffer nodes in ${N}_{2}$. The indegree of each buffer node in ${N}_{2}$ is at least one (and no more than 2), but the outdegree of every big edge node adjacent to the buffer nodes in ${N}_{2}$ is exactly 2. This implies that the ${V}_{big}^{\prime}{N}_{1}\le {N}_{2}$. Putting this together, ${V}_{big}^{\prime}\le {N}_{1}+{N}_{2}={N}_{{G}^{\prime}}({V}_{big}^{\prime})$.
Since
${V}_{big}^{\prime}\le {N}_{{G}^{\prime}}({V}_{big}^{\prime})$, by Hall’s Theorem [
16], a matching covering
${V}_{big}$ exists. Hence, the algorithm computes an orientation if
$OPT\le 1$ and reports
FAIL otherwise.
Consider the orientation produced by the algorithm. If vertex
v has
${\beta}_{v}=k$, then the edge from
v to
${\alpha}_{2}$ in
N has capacity zero which implies that no edge is oriented towards
v, so the load of
v is
${q}_{v}\le 1$. Next we check when
v has
${\beta}_{v}={p}_{v}<k$.
First, let v be a vertex with a big edge oriented towards it. Since a big edge oriented towards v implies a big edge node sends at least $\lceil k/2\rceil $ units of flow to the vertex node for v, at most $(k{p}_{v})\lceil k/2\rceil $ units of flow can be additionally sent to this vertex node by small edge nodes; hence at most $(k{p}_{v})\lceil k/2\rceil $ additional small edges are oriented towards v.
Second, the capacity from any vertex node v to ${\alpha}_{2}$ is $k{p}_{v}$, so any vertex that is not assigned a big edge has at most $k{p}_{v}$ small edges oriented towards it.
Hence, the load of a vertex
v is at most
2.3. Step 5.2
Next, we cover the case when
$1/(k+1)<r\le 1/k$ and
$(k1)/k\le s<k/(k+1)$. In this case, it is possible that
$r+s\le 1$. If
$OPT\le 1$, at most one big edge can be oriented along with one small edge toward the same vertex; we exploit this property below.
Lemma 3. For any $k\ge 2$, there is a polynomialtime algorithm for the graph balancing problem with two rational weights $r,s$, where $1/(k+1)<r\le 1/k$ and $(k1)/k\le s<k/(k+1)$ that either finds a solution of value at most $3/2$ or proves that $OPT>1$.
Proof. We consider two cases: $r+s>1$, and $r+s\le 1$. Assuming $OPT\le 1$, if $r+s>1$ either at most one big edge is oriented towards a vertex or at most k small edges are oriented towards a vertex; apply Lemma 2 to obtain an orientation where each vertex has load at most $3/2$, if such an orientation exists.
From this point forward, assume
$r+s\le 1$. Observe that
$2r+s>1$. If
$OPT\le 1$, an optimal orientation either has at most a big edge oriented along with a small edge towards the same vertex, or at most
k small edges are oriented towards a vertex. Like Lemma 2, compute a value
${\beta}_{v}$ for the dedicated load of each
$v\in V$. When
${q}_{v}\ge r+s$, set
${\beta}_{v}=k$. Otherwise, if
${q}_{v}\ge s$ set
${\beta}_{v}=k1$, and if not, assign
${\beta}_{v}={p}_{v}$ where
${q}_{v}={p}_{v}r$. The algorithm will build a modified version of the flow network
N of Lemma 2, which we describe now. First, change the capacities on the arcs incident on the big edge nodes from
k to
$k1$. Second, for each
$v\in V$, set the capacity of the arc from buffer node
v to vertex node
v to
$k1$ instead of
k. Leave the capacities from the vertex nodes to the sink
${\alpha}_{2}$ as
$k{\beta}_{v}$. We show this flow network in
Figure 2. It is straightforward to see that this modified network maintains the same property that all the arcs leaving
${\alpha}_{1}$ are saturated in an integral maximum flow if
$OPT\le 1$.
We modify the algorithm from Lemma 2 as follows. We refer the reader to BigSmall_
$rs$ (Algorithm 3). The modified flow network we described above is built for Step 1. Steps 2–3 are the same as before. In Step 4, when constructing the bipartite graph
${G}^{\prime}$ between the big edge nodes and buffer nodes,
${V}_{big}$ remains the same, but
${V}_{rec}$ contains buffer nodes that receive instead at least
$\lceil (k1)/2\rceil $ units of flow from a big edge node and
steps 5–8 remain the same as before. Since the capacities of the arcs leaving the buffer nodes and the incoming flow to the big edge nodes are one less than in the network in Lemma 2, one can show a matching on
${G}^{\prime}$ exists if
$OPT\le 1$ by replacing
k with
$k1$ and switching the even and odd cases of our original argument in Lemma 2.
Consider the load of a vertex
v in the orientation produced by the algorithm. Clearly any vertex
v with
${q}_{v}\ge r+s$ has
${\beta}_{v}=k$ and
$k{\beta}_{v}=0$. No flow is sent to these vertex nodes, so the load of these vertices is at most 1. Now, examine vertices with
$0\le {q}_{v}<r+s$. If
${q}_{v}\ge s$, then at most one additional small edge can be oriented towards
v. Hence, the load of
v when
${q}_{v}\ge s$ is at most
${q}_{v}+r\le 1+r\le 3/2$ since
$r\le 1/2$. Finally, consider when
${\beta}_{v}={p}_{v}$ and
${q}_{v}={p}_{v}r<s$.
Let v be a vertex with a big edge oriented towards it. At least $\lceil (k1)/2\rceil $ units of flow are sent from its big edge node to v. Then, at most $(k{p}_{v})\lceil (k1)/2\rceil $ small edges can be oriented along with the big edge towards v.
Let v not have a big edge oriented towards it. At most $k{p}_{v}$ small edges are oriented towards v.
Therefore, the load of
v is at most
2.4. Step 5.3
For the final case in Step 5 of our algorithm, we apply a variant of the algorithm by Ebenlendr
et al. [
7]. First we give a brief explanation of their original algorithm that has approximation ratio
$7/4$.
Let ${E}^{B}$ be the set of big edges and let ${G}^{B}=(V,{E}^{B})$ be the subgraph of G consisting of big edges. If $OPT\le 1$, every connected component of ${G}^{B}$ with b vertices contains at most b edges, which implies that each component has at most one cycle. For each connected component, identify a cycle if it exists, then orient every big edge not in the cycle away from the cycle and remove each oriented edge. Add the weight of each oriented big edge to the dedicated load of the endpoint farther from the cycle. ${G}^{B}$ is now a disjoint union of trees and cycles.
As shorthand, if
v is a vertex and
e is an edge,
$v\in e$ means “
v is incident to
e”. For any
$T\subseteq G$, let
where each
$(v,e)$ is called a
leaf pair of
T. Consider any tree
$T\subseteq {G}^{B}$. Assuming
$OPT\le 1$, since
T has one more vertex than edges, at most one edge in the set of leaf pairs can be oriented away from its leaf. This leads to what is called the
tree constraint (Tree
T) in linear program 1 (LP1) shown below, which is a relaxation of an integer program formulation of the graph balancing problem. A variable
${x}_{ev}$ is defined for each edge
$e\in E$ and endpoint
v of
e. If
${x}_{ev}=1$,
e is oriented towards
v. If
$0<{x}_{ev}<1$, we say that
e is
fractionally oriented towards
v.
Solve LP1 to obtain a fractional solution
$\mathbf{x}$. As a brief remark, there can be exponentially many trees, but there is a separation oracle that can be used to solve LP1 in polynomial time with the ellipsoid method [
7]. Let
${E}_{x}=\{e\in E\phantom{\rule{4pt}{0ex}}\phantom{\rule{4pt}{0ex}}0<{x}_{eu}<1\phantom{\rule{4pt}{0ex}}\text{for}\phantom{\rule{4.pt}{0ex}}u\in e\}$. Also, let
${G}_{x}=(V,{E}_{x})$ and
${G}_{x}^{B}=(V,{E}_{x}\cap {E}^{B})$. If a feasible solution is not found for LP1, then
$OPT>1$.
The algorithm then considers fractionally oriented edges in
${G}_{x}$, and performs a rounding procedure to determine their final orientations. It is assumed that as edges are oriented,
${G}_{x}$ and
${G}_{x}^{B}$ are updated accordingly. If there is a vertex
v of degree 1 in
${G}_{x}$ and
$0<{x}_{ev}<1$ for edge
$e=\{u,v\}$ then
Leaf assignment: if ${p}_{e}{x}_{eu}\le 3/4$, e is oriented towards v;
Tree assignment: if ${p}_{e}{x}_{eu}>3/4$ note that e then is a big edge and the connected component of ${G}_{x}^{B}$ containing e must be a tree T. Orient all edges in T away from v.
Finally, if no vertex v as above is found, then there must be a cycle. If so, perform a walk around the cycle changing the values ${x}_{eu}$ of the edges in the cycle by the minimum amount δ that makes at least one of these values zero and the loads on the vertices remain unchanged. Note that when traversing ${G}_{x}$ to find a cycle, big edges are taken in priority over small edges. This step is called rotation. The algorithm terminates once ${G}_{x}$ no longer has an edge.
The rounding performed by a leaf assignment increases the load of a vertex u by at most $3/4$ if the edge e under consideration is big or it increases by at most $1/2$ if e is small. Furthermore, a tree assignment can increase the load of a vertex u by at most $1/4$. A vertex u can have its load increased by either only one leaf assignment or by a tree assignment plus a leaf assignment involving a small edge. In either case the maximum load of a vertex is at most $7/4$. Note that a rotation does not change loads.
Now we show how to modify this algorithm for our problem.
Lemma 4. For every positive integer $k\ge 2$, there is a polynomialtime algorithm for the graph balancing problem with two rational weights $r,s$, where $1/(k+1)<r\le 1/k$ and $1/2<s<(k1)/k$ that either finds a solution of value at most $3/2$ or proves that $OPT>1$.
Proof. We make the following modifications to the algorithm in [
7]. Consider any tree
$T\subseteq {G}^{B}$. Every big edge
e has weight
${p}_{e}=s$, so we simplify the tree constraint to
Also, in the rounding procedure of [
7] we change the leaf assignment and tree assignment:
New leaf assignment: if ${p}_{e}{x}_{eu}\le 1/2$, e is oriented towards v.
New tree assignment: if ${p}_{e}{x}_{eu}>1/2$, then e is a big edge and the connected component of ${G}_{x}^{B}$ containing e is a tree T. Orient all edges in T away from v.
Use the algorithm of Ebenlendr
et al. [
7] with the above modifications. If no fractional solution is found then no orientation exists; report
FAIL if this is the case. Since modifying the above threshold from
$3/4$ to
$1/2$ will still allow all fractionally oriented edges to be rounded, the algorithm still finds an orientation in polynomial time.
We can extend the arguments by Ebenlendr
et al. [
7] to show that the algorithm has approximation ratio
$3/2$ in our case. It is not hard to modify the proof of Theorem 1 in [
7] to show that the following conditions are maintained by each vertex
$v\in V$ before and after each step in the rounding procedure.
 (1)
The load of v is at most $3/2$.
 (2)
If $e\in {G}_{x}$ is incident on v, then v has load at most $1+(s1/2)$.
 (3)
If ${e}_{B}$ is a big edge in ${G}_{x}^{B}$ incident on v, the load of v is at most 1.
 (4)
For any tree T that is a subgraph of ${G}_{x}^{B}$, the tree constraint (Tree T) is never violated.
For completeness we sketch a proof that the above conditions hold throughout the rounding procedure. At the beginning of the algorithm, after the modified LP1 is solved, all the conditions above are satisfied and the load of each vertex is at most 1. Next, we show conditions (1)–(4) are preserved for any vertex that changes its load during the rounding procedure.
Tree assignment: In a tree assignment, only vertices in the tree
$T\subseteq {G}_{x}^{B}$ containing big edge
$e=\{u,v\}$ for which
${p}_{e}{x}_{eu}>1/2$ and
v is a leaf of
T have their loads modified. Every vertex in
T is incident with a big edge in
${G}_{x}$. Hence before this step is performed, by condition (3), each one of these vertices has load at most 1. Consider vertex
${u}^{\prime}$ in
T after the tree assignment has been performed. If
${u}^{\prime}=v$, the load of
v is decreased as big edges are oriented away from
v. If
${u}^{\prime}\ne v$, there exists a path
P in
T from
${u}^{\prime}$ to
v. Say this path begins at edge
${e}^{\prime}$. As
P is a subtree of
T, it must satisfy our tightened tree constraint of LP1 and so
All the edges in
P are big, so
$s{x}_{{e}^{\prime}{u}^{\prime}}\ge s{x}_{eu}>1/2$. Hence, the load of
${u}^{\prime}$ increases by at most
$ss{x}_{{e}^{\prime}{u}^{\prime}}<s1/2$, and conditions (1) and (2) are satisfied for vertex
${u}^{\prime}$. Note that since fractional edge assignments in
T have been eliminated,
${u}^{\prime}$ cannot be incident on a big edge following a tree assignment. Thus, condition (3) does not apply to this case and condition
$(4)$ is satisfied.
Leaf assignment: In a leaf assignment, edges are oriented towards a leaf vertex. Say vertex v is a leaf. We consider two cases for edge $e=\{u,v\}$ such that ${p}_{e}{x}_{eu}\le 1/2$: ${p}_{e}>1/2$, and ${p}_{e}\le 1/2$.
If ${p}_{e}>1/2$, then v is incident on a big edge and so by condition (3), the load of v is at most 1 before the leaf assignment. Since ${p}_{e}{x}_{ev}{p}_{e}={x}_{eu}{p}_{e}\le 1/2$, then following the leaf assignment, the load of v is at most $1+1/2=3/2$.
If
${p}_{e}\le 1/2$, then
${p}_{e}=r$. By condition (2), before the leaf assignment the load of
v is at most
$1+(s1/2)$. So after the leaf assignment the load of
v is at most
In any case, after a leaf assignment
v is isolated in
${G}_{x}$, so conditions
$(1)$–
$(4)$ are satisfied.
Rotation: The rotation step does not change the vertex loads so conditions (1)–(3) hold. The argument showing that condition (4) holds is essentially the same as that in [
7] and since it is a bit lengthy we omit it here.
Therefore, by condition (1), the load of a vertex is at most $3/2$. ☐