Ticket #8893: trac_8893.patch

File trac_8893.patch, 2.4 KB (added by ncohen, 9 years ago)
  • sage/graphs/generic_graph.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1273357463 14400
    # Node ID ef69d39215c0dcf16fe240aa55fb21af1ab9486e
    # Parent  c9bdfb54f113ef8dc3a1bfa217ce8ebb6afb2546
    [mq]: disjoint
    
    diff -r c9bdfb54f113 -r ef69d39215c0 sage/graphs/generic_graph.py
    a b  
    42004200
    42014201        return h
    42024202
     4203    def disjoint_routed_paths(self,pairs, solver=None, verbose=0):
     4204        r"""
     4205        Returns a set of disjoint routed paths.
     4206
     4207        Given a set of pairs `(s_i,t_i)`, a set
     4208        of disjoint routed paths is a set of
     4209        `s_i-t_i` paths which can interset at their endpoints
     4210        and are vertex-disjoint otherwise.
     4211
     4212        INPUT:
     4213
     4214        - ``pairs`` -- list of pairs of vertices
     4215
     4216        - ``solver`` -- Specify a Linear Program solver to be used.
     4217          If set to ``None``, the default one is used.
     4218          function of ``MixedIntegerLinearProgram``. See the documentation  of ``MixedIntegerLinearProgram.solve``
     4219          for more informations.
     4220
     4221        - ``verbose`` (integer) -- sets the level of verbosity. Set to `0`
     4222          by default (quiet).
     4223
     4224        EXAMPLE:
     4225       
     4226        Given a grid, finding two vertex-disjoint
     4227        paths, the first one from the top-left corner
     4228        to the bottom-left corner, and the second from
     4229        the top-right corner to the bottom-right corner
     4230        is ... easy ::
     4231
     4232            sage: g = graphs.GridGraph([5,5])
     4233            sage: p1,p2 = g.disjoint_routed_paths( [((0,0), (0,4)), ((4,4), (4,0))]) # optional - requires GLPK CBC or CPLEX
     4234
     4235        Though there is obviously no solution to the problem
     4236        in which each corner is sending information to the opposite
     4237        one::
     4238
     4239            sage: g = graphs.GridGraph([5,5])
     4240            sage: p1,p2 = g.disjoint_routed_paths( [((0,0), (4,4)), ((0,4), (4,0))]) # optional - requires GLPK CBC or CPLEX
     4241            Traceback (most recent call last):
     4242            ...
     4243            ValueError: The disjoint routed paths do not exist.
     4244        """
     4245
     4246        try:
     4247            return self.multicommodity_flow(pairs, vertex_bound = True, solver=solver, verbose=verbose)
     4248        except ValueError:
     4249            raise ValueError("The disjoint routed paths do not exist.")
     4250
    42034251    def edge_disjoint_paths(self, s, t):
    42044252        r"""
    42054253        Returns a list of edge-disjoint paths between two