The base scenario is this: We're given a weighted, directed graph $G= (V,E)$, and are tasked to find an approximating algorithm which returns a digraph $G' = (V,E')$ (i.e. which only deletes edges) so that $G'$ is acyclic, and so that the sum of the weights of the remaining edges $\sum_{e\in E'} weight(e)$ is as big as possible.

Furthermore, the approximation shall be at worst half as good as the optimal solution (i.e. the sum of weights the approximation algorithm returns is at least half as big as the sum of weights of the optimal solution)

This is a homework problem, and I'm looking for hints how to solve it, as I can't seem to figure out any tactic to somehow compare the approximation algorithm ideas to any bound on the optimum solution.

I've come up with 4 ideas of choosing nodes/edges, from which 2 could go arbitrarily bad, and from which I believe 4) has the best chance of succeeding.

So far I have the following results:

Using an algorithm to identify the strongly connected components, I can partition $G$ into a set of subgraphs (one for every strongly connected component), and solve for each subgraph individually (all edges between these subgraphs never create a cycle, and can always be taken into the solution).

Using the tactic to iteratively identify a cycle and remove the one edge of it which has the lowest weight can go arbitrarily bad .

The optimal subgraph $\hat G = (\hat V, \hat E)$ has a topological sorting.
Therefore, there exists a numbering $v_1,..,v_{|V|}$ of the nodes so that with $T:= [v_1,..,v_{|V|}]$, the sum $$\sum_{j=1}^n \sum_{ k=2}^j weight(v_j\to v_k) $$ is minimal. (The sum represents for each node $v$ in $T$ the weight of all edges $(v,v')$ that is lost because $v'$ appears before $v$ in the list, and thus there mustn't exist an edge $v\to v'$

Therefore, an approximation algorithm might guess the topological sorting of the optimal graph.

Going from left to right, and always picking the node that brings with it the highest weight (as sum of its outgoing edges that are eligible) can go arbitrarily bad.

However, so far I haven't found any counter-example for going from right to left, and always picking the node which loses the least weight.

For the last approach, we can show the following inequality:
Let $T:= [v_1,..,v_{n}]$ be the result of the approximation algorithm, then holds: $$ \sum_{k=1}^{j-1} weight(v_j\to v_{k}) \le \sum_{j=2}^n\sum_{k=2}^j weight(v_1\to v_k) = \sum_{j=1}^{n-1} (n-j)weight(v_1\to v_j) $$

  • $\begingroup$ Your graphs are directed and weighted, right? By default, the word "graph" on its own implies undirected and unweighted. $\endgroup$ Commented Feb 3, 2019 at 22:16
  • $\begingroup$ @DavidRicherby Yes, they're directed and weighted - I'll add that to the question $\endgroup$
    – Sudix
    Commented Feb 3, 2019 at 22:52
  • $\begingroup$ Hint: Any vertex ordering gives you two "natural" subsets of edges to consider that are clearly both acyclic. $\endgroup$ Commented Feb 4, 2019 at 2:33
  • $\begingroup$ @j_random_hacker I've got it! Though I have to say, this kind of upper bound on the optimum is simply stupid... $\endgroup$
    – Sudix
    Commented Feb 4, 2019 at 13:34

1 Answer 1


First: The upper bound is as stupid as they come: Namely, that at most, the optimal solution contains all edges.

With this upper bound, our approximating algorithm now asserts the following statement:
In every weighted, directed graph $G =(V,E)$ there exists a subgraph $G' = (V,E'), E'\subseteq E$ so that $G'$ is acyclic, and $\sum_{e\in E'} weight(e) \ge \frac 1 2 \sum_{e\in E} weight(e)$,
i.e. we can choose the edges in $E'$ so that they accumulate at least half of the weight of all edges in $E$.

To find such a graph $G'$, we enumerate the vertices in $V$ as $x_1,...,x_n$, and now create two edge sets using it: $$ E_1 = \{(x_i,x_j)\in E\mid x_i<x_j \} \\ E_2 = \{(x_i,x_j)\in E\mid x_i>x_j \} $$ Differently put, imagine the graph $G$. Now move the vertices, so that they form the line $x_1,...,x_n$ from left to right (while keeping the edges intact).
Now, for $E_1$, you remove all edges going left.
For $E_2$, you remove all edges going right.

Each of the corresponding graphs $G_1 := (V,E_1), G_2:=(V,E_2)$ is acyclic, and $E_1\dot\cup E_2=E$, i.e. $E_1, E_2$ contain all edges in $E$ exactly once.

Therefore, either $G_1$ or $G_2$ has to contain at least half of the edge weight, and thus one of them is the wanted subgraph.

  • $\begingroup$ Nice job! It seems a little surprised you can enumerate vertices in any order, but it makes sense. Do you have any guarantee that the result is connected? $\endgroup$ Commented May 7, 2021 at 21:57
  • $\begingroup$ @JustinMeiners Given that the resulting graph is directed and acyclic, it'd be more fitting to ask whether or not it is a tree. Since the result basically says that for any partition of the edges $E_1\dot\cup E_2=E$ so that both resulting graphs $G(V,E_1), G(V,E_2)$ are acyclic, either $G(V,E_1), G(V,E_2)$ is our half approximation, your question is then whether or not we can find such a partition, so that you can add to both generated graphs edges so that they become trees. However, the scope of your question is too big for a comment, so you should post is as question. $\endgroup$
    – Sudix
    Commented May 8, 2021 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.