Ticket #9910: trac_9910-fixing_documentation.patch

File trac_9910-fixing_documentation.patch, 4.2 KB (added by ncohen, 10 years ago)
  • sage/graphs/generic_graph.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1290933350 -3600
    # Node ID c2a15810aa6f0a6e930a036bc889ca57b5974965
    # Parent  9a5f569d00d280dfd09ba4f2417ab8745d5c6b3c
    trac 9910 -- fixing the documentation in Graph.longest_path
    
    diff -r 9a5f569d00d2 -r c2a15810aa6f sage/graphs/generic_graph.py
    a b  
    43804380
    43814381        INPUT:
    43824382
    4383         - ``s`` (vertex) -- forces the source of the path. Set to
    4384           ``None`` by default.
    4385 
    4386         - ``t`` (vertex) -- forces the destination of the path. Set to
    4387           ``None`` by default.
    4388 
    4389         - ``weighted`` (boolean) -- whether the labels on the edges are
    4390           to be considered as weights (a label set to ``None`` or
    4391           ``{}`` being considered as a weight of `1`). Set to
    4392           ``False`` by default.
    4393 
    4394         - ``algorithm`` -- one of ``"MILP"`` (default) or
    4395           ``"backtrack"``. Two remarks on this respect:
    4396 
    4397               * While the MILP formulation returns an exact answer,
    4398                 the backtrack algorithm is a randomized heuristic.
    4399 
    4400               * As the backtrack algorithm does not support edge
    4401                 weighting, setting ``weighted=True`` will force
    4402                 the use of the MILP algorithm.
     4383        - ``s`` (vertex) -- forces the source of the path (the method then
     4384          returns the longest path starting at ``s``). The argument is set to
     4385          ``None`` by default, which means that no constraint is set upon the
     4386          first vertex in the path.
     4387
     4388        - ``t`` (vertex) -- forces the destination of the path (the method then
     4389          returns the longest path ending at ``t``). The argument is set to
     4390          ``None`` by default, which means that no constraint is set upon the
     4391          last vertex in the path.
     4392
     4393        - ``weighted`` (boolean) -- whether the labels on the edges are to be
     4394          considered as weights (a label set to ``None`` or ``{}`` being
     4395          considered as a weight of `1`). Set to ``False`` by default.
     4396
     4397        - ``algorithm`` -- one of ``"MILP"`` (default) or ``"backtrack"``. Two
     4398          remarks on this respect:
     4399
     4400              * While the MILP formulation returns an exact answer, the
     4401                backtrack algorithm is a randomized heuristic.
     4402
     4403              * As the backtrack algorithm does not support edge weighting,
     4404                setting ``weighted=True`` will force the use of the MILP
     4405                algorithm.
    44034406
    44044407        - ``solver`` -- (default: ``None``) Specify the Linear Program (LP)
    44054408          solver to be used. If set to ``None``, the default one is used. For
     
    44144417
    44154418        .. NOTE::
    44164419
    4417             The length of a path is assumed to be the number of its
    4418             edges, or the sum of their labels.
     4420            The length of a path is assumed to be the number of its edges, or
     4421            the sum of their labels.
    44194422
    44204423        OUTPUT:
    44214424
    4422         A subgraph of ``self`` corresponding to a (directed if
    4423         ``self`` is directed) longest path. If ``weighted == True``, a
    4424         pair ``weight, path`` is returned.
     4425        A subgraph of ``self`` corresponding to a (directed if ``self`` is
     4426        directed) longest path. If ``weighted == True``, a pair ``weight, path``
     4427        is returned.
    44254428
    44264429        ALGORITHM:
    44274430
    4428         Mixed Integer Linear Programming. (This problem is known to be
    4429         NP-Hard).
     4431        Mixed Integer Linear Programming. (This problem is known to be NP-Hard).
    44304432
    44314433        EXAMPLES:
    44324434
     
    44444446            sage: g.longest_path(algorithm="backtrack").edges()
    44454447            [(0, 1, None), (1, 2, None), (2, 3, None), (3, 4, None), (4, 9, None), (5, 7, None), (5, 8, None), (6, 8, None), (6, 9, None)]
    44464448
    4447         Let us compute longest paths on random graphs with random
    4448         weights. Each time, we ensure the resulting graph is indeed a
    4449         path::
     4449        Let us compute longest paths on random graphs with random weights. Each
     4450        time, we ensure the resulting graph is indeed a path::
    44504451
    44514452            sage: for i in range(20):
    44524453            ...       g = graphs.RandomGNP(15, 0.3)