Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove cycles in an unweighted directed graph, such that the number of edges is maximised?

Let G be an unweighted directed graph containing cycles. I'm looking for an algorithm which finds/creates all acyclic graphs G', composed of all vertices in G and a subset of edges of G, just small enough to make G' acyclic.

More formal: The desired algorithm consumes G and creates a set of acyclic graphs S, where each graph G' in S satisfies following properties:

  1. G' contains all vertices of G.
  2. G' contains a subset of edges of G, such that G' is acyclic.
  3. The number of edges of G' is maximised. Which means: There is no G'' satisfying properties 1 and 2, such that G'' contains more edges then G' and G'' is acyclic.

Background: The original graph G models a pairwise ordering between elements. This can't be exploited as an ordering over all elements due to cycles in the graph. The maximal acyclic graphs G' therefore should model a best-possible approximation to this ordering, trying to respect as much of the pairwise ordering relation as possible.

In a naive approach, one could remove all possible combinations of edges and check for acyclicity after each removal. In this case there is a strongly branching tree of variations meaning bad time and space complexity.

Note: The problem may be related to a spanning tree, and you could define the G' graphs as a kind of directed spanning tree. But keep in mind that in my scenario a pair of edges in G' may have the same starting or the same ending vertex. This conflicts with some definitions of directed spanning trees used in literature.

EDIT: Added intuitive description, background information and note related to spanning trees.

like image 796
mtsz Avatar asked Jun 08 '11 19:06

mtsz


People also ask

How do you remove cycles from a directed graph?

The main objective is to eliminate the cycle in the task graph, so that it becomes acyclic. One way to do this is simply drop edges from the task graph to break the cycle. A feedback arc set or feedback edge set is a set of edges which when removed from the graph will leave a DAG.

How many edges does a cycle graph have?

A Cycle Graph is 3-edge colorable or 3-edge colorable, if and only if it has an odd number of vertices. In a Cycle Graph, Degree of each vertex in a graph is two.

How do you find the maximum number of edges on a graph?

A complete graph has the maximum number of edges, which is given by n choose 2 = n*(n-1)/2.

How do you determine the number of cycles in a graph?

Here for finding the number of cycles in the undirected graph, the time complexity is the same as DFS traversal, i.e., O(V+E), where V is the number of vertices and E is the number of edges in the graph.


1 Answers

This problem is called Feedback Arc Set. Since it is NP-hard, it is unlikely that you will find a scalable fast algorithm. However, if your instances are small, then algorithms such as the one from the paper “On enumerating all minimal solutions of feedback problems” by B. Schwikowski and E. Speckenmeyer might work.

like image 160
Falk Hüffner Avatar answered Sep 26 '22 14:09

Falk Hüffner