Advanced maths

Minimum directed feedback arc set calculator with topological order

Remove directed arcs at minimum total cost until every directed cycle is broken.

Your numbers

Vertices are labeled consecutively from 1 through this number, including isolates.
One source,destination,cost row per arc. Opposite arcs allowed; no loops or duplicate ordered pairs.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Remove directed arcs at minimum total cost until every directed cycle is broken. The output identifies the removed arcs and a topological order of the remaining digraph. Costs belong to arcs, while every vertex remains present, making this a different intervention from deleting a feedback vertex set.

THE FORMULAD(S)=min_{v∈S}[D(S\{v})+Σ_{u∈S\{v}} w(v,u)]; D(∅)=0; backward arcs are removed.

A worked example

Arcs 1→2 cost 4, 2→3 cost 3, 3→1 cost 2, 1→3 cost 1: remove 3→1 at cost 2. Order 1,2,3 is valid; the directed triangle forces cost at least 2.

Good to know

Simple directed graph, 1–9 vertices, integer arc weights 0–1,000,000. Exact subset DP; opposite arcs allowed, duplicate ordered pairs and loops rejected. Minimum cost, not secondary minimum cardinality.

Breaking circular dependencies

A directed feedback arc set intersects every directed cycle. After removing those arcs, the remaining dependency network admits an ordering in which every retained arc points forward; this topological order is an inspectable feasibility witness.

Deleting an arc can represent relaxing a dependency, but the mathematics does not decide whether that relaxation is operationally allowed. Encode the permitted costs carefully before interpreting the minimum as an implementation recommendation.

Minimum directed feedback arc set calculator with topological order worked exampleBreak the directed triangle12343remove 2Delete 3 to 1; retained arcs point forward
Arcs 1→2 cost 4, 2→3 cost 3, 3→1 cost 2, 1→3 cost 1: remove 3→1 at cost 2. Order 1,2,3 is valid; the directed triangle forces cost at least 2.

Compare this with the Minimum feedback vertex set calculator for a directed graph. Removing vertices and removing arcs are different optimization problems and witnesses.

Why orders solve the optimization

For any vertex order, deleting all backward arcs produces an acyclic graph. Conversely, every acyclic remainder has a topological order, and every backward arc of that order must have been removed from the original graph.

With nonnegative costs, unnecessary forward-arc deletions can be restored without increasing the required objective. Therefore minimizing the sum of backward-arc costs over all orders gives exactly the minimum feedback arc cost.

Building an order by subsets

A dynamic-programming state stores the cheapest ordering of a vertex subset. If vertex v is placed last, arcs from v to earlier vertices become backward and their costs are added to the best ordering of the remaining subset.

The algorithm tests every possible last vertex for each subset and reconstructs an optimal order from the stored choices. This is a complete exact optimization under the stated cap, rather than a ranking heuristic that may stop at a local arrangement.

Checking the weighted triangle

The default arcs are 1 to 2 with cost four, 2 to 3 with cost three, 3 to 1 with cost two, and 1 to 3 with cost one. The first three arcs form a directed triangle.

Deleting 3 to 1 costs two and leaves order 1, 2, 3 valid. Every feasible deletion must break that triangle, whose cheapest arc costs two; the witness therefore meets a matching lower bound and proves optimality.

Inspecting the removal witness

Check each retained arc against the reported order: its source must appear before its destination. The displayed removal weight should equal the sum of costs on the explicitly listed removed arcs, including any zero-cost arcs selected by the order.

There can be many optimal orders and many optimal removal sets. A zero-cost arc may be removed without changing the objective, so minimum total weight does not necessarily mean the smallest possible number of removed arcs.

Entering arcs and costs

Use one through nine vertices with one row for each ordered source, destination and nonnegative integer cost. Opposite arcs are distinct and allowed, while duplicate ordered pairs and self-loops are rejected by this input model.

Costs range from zero to one million. Restricting them to bounded integers preserves exact sums and comparisons; negative costs would reward unnecessary deletion and require a different statement of the ordering argument used here.

What the result does not optimize

All vertices remain available, and removing an arc does not reverse it. A feedback vertex set, arc reversal problem and minimum violation ranking can have related formulations but different operational meanings and different witnesses.

The reported order certifies acyclicity of the remainder, not execution duration or a critical path. Durations, resource availability and precedence alternatives must be modeled separately before this graph edit becomes a full scheduling plan.

A few questions, answered

Are opposite directed arcs allowed?

Yes. They form a directed two-cycle, so at least one must be removed.

Are negative costs supported?

No. Use integer arc costs from zero through one million.

Can a zero optimum still remove arcs?

Yes. Zero-cost arcs can be removed to break cycles without increasing the objective.

Does the calculator delete any vertices?

No. Every declared vertex remains; only arcs are selected for removal.

Find your calculator

Start typing to explore the library.