# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1371130035 7200
# Node ID 7a274e4897e6d9239ab357715bfd979801c1cf87
# Parent 496e406a2a756582dd1666e38b5815f17e2b70a4
Implement feedback_vertex_set for graphs  a bug in is_tree
diff git a/sage/graphs/graph.py b/sage/graphs/graph.py
a

b


1690  1690  sage: 1 in cycle 
1691  1691  True 
1692  1692  
 1693  TESTS: 
 1694  
 1695  :trac:`14434` is fixed:: 
 1696  
 1697  sage: g = Graph({0:[1,4,5],3:[4,8,9],4:[9],5:[7,8],7:[9]}) 
 1698  sage: _,cycle = g.is_tree(certificate=True) 
 1699  sage: g.size() 
 1700  10 
 1701  sage: g.add_cycle(cycle) 
 1702  sage: g.size() 
 1703  10 
1693  1704  """ 
1694  1705  
1695  1706  if self.order() == 0: 
… 
… 

1707  1718  n = self.order() 
1708  1719  seen = {} 
1709  1720  u = self.vertex_iterator().next() 
1710   v = self.neighbor_iterator(u).next() 
1711  1721  seen[u] = u 
1712   stack = [(u,v)] 
 1722  stack = [(u,v) for v in self.neighbor_iterator(u)] 
1713  1723  while stack: 
1714  1724  u,v = stack.pop(1) 
1715  1725  if v in seen: 
… 
… 

1754  1764  sage: g.is_forest(certificate = True) 
1755  1765  (True, None) 
1756  1766  sage: (2*g + graphs.PetersenGraph() + g).is_forest(certificate = True) 
1757   (False, [60, 61, 62, 63, 64]) 
 1767  (False, [63, 62, 61, 60, 64]) 
1758  1768  """ 
1759  1769  number_of_connected_components = len(self.connected_components()) 
1760  1770  isit = (self.num_verts() == 