# Ticket #12136: trac_12136.patch

File trac_12136.patch, 1.8 KB (added by fichtejo, 17 months ago)
• ## sage/graphs/digraph.py

```# HG changeset patch
# User Johannes Klaus Fichte <fichte@kr.tuwien.ac.at>
# Date 1324621964 -3600
# Node ID 092dc01ded091da2bae330d4e9b20e320f85d039
# Parent  df5620969fbddef0cf191407d046c2ed522d6a49
Ticket #12136
FVS function in DiGraph returns [0] instead of [] if already directed acyclic
-> feedback vertex set returns empty list, if the graph is directed acyclic

diff --git a/sage/graphs/digraph.py b/sage/graphs/digraph.py```
 a b_sol=p.get_values(b) from sage.sets.set import Set return Set([(u,v) for (u,v) in self.edges(labels=None) if b_sol[(u,v)]==1]) return [(u,v) for (u,v) in self.edges(labels=None) if b_sol[(u,v)]==1] def feedback_vertex_set(self, value_only=False, solver=None, verbose=0, constraint_generation = True): r""" if self.is_directed_acyclic(): if value_only: return 0 from sage.sets.set import Set return Set([0]) return [] from sage.numerical.mip import MixedIntegerLinearProgram, Sum else: # listing the edges contained in the MFAS from sage.sets.set import Set return Set([v for v in self if p.get_values(b[v]) > .5]) return [v for v in self if p.get_values(b[v]) > .5] else: p.solve(log=verbose) b_sol=p.get_values(b) from sage.sets.set import Set return Set([v for v in self if b_sol[v]==1]) return [v for v in self if b_sol[v]==1] ### Construction