# Ticket #8798: trac_8798-rebased.patch

File trac_8798-rebased.patch, 9.5 KB (added by mvngu, 11 years ago)
• ## sage/graphs/generic_graph.py

# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1272442371 -7200
# Node ID 14825bd6369b50415a3dc8184ae20157e84ca4aa
# Parent  9188e33e33ed5708fcccff34d429d701dec3baaa
trac 8798 : remove duplicates of feedback_vertex_set and feedback_edge_set from generic_graph.py

diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
 a else: raise ValueError("Only two algorithms are available : Cliquer and MILP.") 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 information, see the Wikipedia article on feedback arc sets _. 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_. INPUT : - value_only (boolean) -- - When set to True, only the minimum cardinal of a minimum vertex set is returned. - When set to False, the Set of vertices of a minimal feedback vertex set is returned. This problem is solved using Linear Programming, which certainly is not the best way and will have to be replaced by a better algorithm. The program solved is the following : .. MATH: \mbox{Minimize : }&\sum_{v\in G} b_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+nb_v\geq 0\\ A brief 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