Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As the title says, I am looking for a way to find the minimum number of links to remove from a directed graph to make it acyclic. I am looking both for the minimum number, as well as an actual set of links to remove.

How can this be done in a reasonably simple and efficient way?

EDIT: In other words, how can I label/order the vertices of the graph so that the adjacency matrix will contain most (nonzero) elements below the diagonal?

share|cite|improve this question
You may find Menger's Theorem for digraphs useful.… – Austin Mohr Oct 12 '11 at 12:19
Would it work to just find the vertex with the least number of incoming edges and remove those? Then you have a vertex that can never be reached, hence acyclic. – Dan W Oct 12 '11 at 20:37
An acyclic graph contains no cycles at all, rather than merely a vertex that's not in a cycle. – jwpat7 Oct 12 '11 at 21:26
up vote 4 down vote accepted

This problem is well-known under the name minimum feedback arc set problem. The decision version of the problem says: given a graph $G$ and a parameter $k$, can we break all cycles in $G$ by deleting some set of at most $k$ arcs from it? [Note that, as usual, the decision version is no harder than the computational one of finding the minimum feedback arc set. ]

The above decision version of this problem is NP-complete. In fact, it is one of Richard Karp's 21 NP-completeness problems. That is, unless NP collapses to P--widely believed to be unlikely--this problem will not admit a polynomial time algorithm. You can look up the details from the wikipedia page.

share|cite|improve this answer
Thanks! I didn't expect an answer so long after asking the question – Szabolcs Nov 14 '11 at 19:40
@Szabolcs You are quite welcome. I guess thanks are due also to Community for poking old unanswered posts. =) – Srivatsan Nov 14 '11 at 19:44

You can start off by finding all cycles in the graph. You can be sure that, for each cycle, at least one of the edges (links) in it are going to be removed. You save for each edge, how many cycles it is contained in. Then, start removing edges greedily until all cycles are gone. This isn't very efficient, though.

share|cite|improve this answer
Can you prove that this will give the minimum number of edges to be removed? Also, can you suggest a way to find all cycles? I think the total number of cycles will grow extremely fast with the vertex count in a sufficiently dense graph. – Szabolcs Oct 17 '11 at 14:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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