# HG changeset patch
# User Nathann Cohen
# Date 1253385913 -7200
# Node ID b2af0a8f0e5b97688407e37af24ed355592c8221
# Parent 021c67fcbec41f970d52b920b30ab91a28dd5cd8
Adds the functions :
* DiGraph.feedback_edge_set
* DiGraph.feedback_vertex_set
diff -r 021c67fcbec4 -r b2af0a8f0e5b sage/graphs/graph.py
--- a/sage/graphs/graph.py Wed Dec 16 12:33:12 2009 +0100
+++ b/sage/graphs/graph.py Sat Sep 19 20:45:13 2009 +0200
@@ -12471,6 +12471,224 @@
"""
return sorted(self.out_degree_iterator(), reverse=True)
+
+ def feedback_edge_set(self,value_only=False):
+ r"""
+ Computes the minimum feedback edge set of a digraph
+ ( also called feedback arc set ).
+
+ The minimum feedback edge set of a digraph is a set of edges
+ that intersect all the circuits of the digraph.
+ Equivalently, a minimum feedback arc set of a DiGraph is a set
+ `S` of arcs such that the digraph `G-S` is acyclic.
+
+ For more informations, see
+ ( http://en.wikipedia.org/wiki/Feedback_arc_set )
+
+ INPUT :
+
+ - ``value_only`` (boolean) --
+ - When set to ``True``, only the minimum
+ cardinal of a minimum edge set is
+ returned.
+
+ - When set to ``False``, the ``Set`` of edges
+ of a minimal edge set is returned.
+
+ This problem is solved using Linear Programming, which certainly
+ is not the best way and will have to be updated. The program solved
+ is the following :
+
+ .. MATH:
+ \mbox{Minimize : }&\sum_{(u,v)\in G} b_{(u,v)}\\
+ \mbox{Such that : }&\\
+ &\forall v\in G, \sum_{i\in [0,\dots,n-1]}x_{v,i}=1\\
+ &\forall i\in [0,\dots,n-1], \sum_{v\in G}x_{v,i}=1\\
+ &\forall v\in G,\sum_{i\in [0,\dots,n-1]} ix_{v,i}=d_v\\
+ &\forall (u,v)\in G, d_u-d_v+nb_{(u,v)}\geq 0\\
+
+ An explanation :
+
+ An acyclic digraph can be seen as a poset, and every poset has
+ a linear extension. This means that in any acyclic digraph
+ the vertices can be ordered with a total order `<` in such a way
+ that if `(u,v)\in G`, then `u