Ticket #9422: trac_9422.patch

File trac_9422.patch, 877 bytes (added by ncohen, 11 years ago)
  • sage/graphs/generic_graph.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1278243971 -7200
    # Node ID 099359f37e4d2e274c9cc090f310568c055b9bb0
    # Parent  556bb66e4c6dbb92a4ee37c1750d82a5c6298eeb
    trac 9422 -- Slightly improving is_forest
    
    diff -r 556bb66e4c6d -r 099359f37e4d sage/graphs/generic_graph.py
    a b  
    18191819            sage: seven_acre_wood.is_forest()
    18201820            True
    18211821        """
    1822         for g in self.connected_components_subgraphs():
    1823             if not g.is_tree():
    1824                 return False
    1825         return True
     1822        number_of_connected_components = len(self.connected_components())
     1823
     1824        return self.num_verts() == self.num_edges() + number_of_connected_components
    18261825
    18271826    def order(self):
    18281827        """