Ticket #7289: trac_7289-part2.patch

File trac_7289-part2.patch, 3.2 KB (added by rlm, 11 years ago)
  • sage/graphs/generic_graph.py

    # HG changeset patch
    # User Robert L. Miller <rlm@rlmiller.org>
    # Date 1276903266 25200
    # Node ID 0239cc2433639437bbd17c179724f92250b227e3
    # Parent  6164f5b70f7415c9d7bd35b3cb49d7ce2fb159d7
    #7289: multiway cut, part 2 (editing etc.)
    
    diff -r 6164f5b70f74 -r 0239cc243363 sage/graphs/generic_graph.py
    a b  
    33613361        represented by a list of edges.
    33623362   
    33633363        A multiway cut for a vertex set `S` in a graph or a digraph
    3364         `G` if a set `C` of edges such that any two vertices `u,v`
    3365         in `S` are disconnected when removing from `G` the edges from
    3366         `C`.
     3364        `G` is a set `C` of edges such that any two vertices `u,v`
     3365        in `S` are disconnected when removing the edges from `C` from `G`.
    33673366
    33683367        Such a cut is said to be minimum when its cardinality
    33693368        (or weight) is minimum.
     
    33973396        to a minimum edge cut ::
    33983397
    33993398            sage: g = graphs.PetersenGraph()
    3400             sage: g.edge_cut(0,3) == g.multiway_cut([0,3], value_only = True) # optional - requires GLPK, CBC or CPLEX
     3399            sage: g.edge_cut(0,3) == g.multiway_cut([0,3], value_only = True) # optional - GLPK, CBC
    34013400            True
    34023401
    34033402        As Petersen's graph is `3`-regular, a minimum multiway cut
     
    34053404        (which could correspond to the neighborhood of 2
    34063405        vertices)::
    34073406
    3408             sage: g.multiway_cut([0,3,9], value_only = True) == 2*3          # optional - requires GLPK, CBC or CPLEX
     3407            sage: g.multiway_cut([0,3,9], value_only = True) == 2*3          # optional - GLPK, CBC
    34093408            True
    34103409
    34113410        In this case, though, the vertices are an independent set.
    34123411        If we pick instead vertices `0,9,` and `7`, we can save `4`
    34133412        edges in the multiway cut ::
    34143413
    3415             sage: g.multiway_cut([0,7,9], value_only = True) == 2*3 - 1      # optional - requires GLPK, CBC or CPLEX
     3414            sage: g.multiway_cut([0,7,9], value_only = True) == 2*3 - 1      # optional - GLPK, CBC
    34163415            True
    34173416
    34183417        This example, though, does not work in the directed case anymore,
    34193418        as it is not possible in Petersen's graph to mutualise edges ::
    34203419       
    34213420            sage: g = DiGraph(g)
    3422             sage: g.multiway_cut([0,7,9], value_only = True) == 3*3           # optional - requires GLPK, CBC or CPLEX
     3421            sage: g.multiway_cut([0,7,9], value_only = True) == 3*3           # optional - GLPK, CBC
    34233422            True
    34243423
    34253424        Of course, a multiway cut between the whole vertex set
    34263425        contains all the edges of the graph::
    34273426
    3428             sage: C = g.multiway_cut(g.vertices())                            # optional - requires GLPK, CBC or CPLEX
    3429             sage: set(C) == set(g.edges())                                    # optional - requires GLPK, CBC or CPLEX
     3427            sage: C = g.multiway_cut(g.vertices())                            # optional - GLPK, CBC
     3428            sage: set(C) == set(g.edges())                                    # optional - GLPK, CBC
    34303429            True
    34313430        """
    34323431        from sage.numerical.mip import MixedIntegerLinearProgram