Ticket #7288: trac_7288_review-abm.patch

File trac_7288_review-abm.patch, 10.2 KB (added by abmasse, 11 years ago)

Minor doc fixes -- apply on top of Nathann's patch

  • sage/graphs/generic_graph.py

    # HG changeset patch
    # User Alexandre Blondin Masse < alexandre.blondin.masse at gmail.com>
    # Date 1268436328 -3600
    # Node ID 68925297a11a25f476055d3d6fb2dee8af169286
    # Parent  b0881d4b8428102cd7e0aa8238061f2cae119666
    #7288 Minor doc and comments fixes
    
    diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
    a b class GenericGraph(GenericGraph_pyx): 
    30283028        represented by a list of edges.
    30293029
    30303030        A minimum edge cut between two vertices `s` and `t` of self
    3031         is a set `U` of edges of minimum weight such that the graph
    3032         obtained by removing `U` from self is disconnected.
     3031        is a set `A` of edges of minimum weight such that the graph
     3032        obtained by removing `A` from self is disconnected.
    30333033        ( cf. http://en.wikipedia.org/wiki/Cut_%28graph_theory%29 )
    30343034       
    30353035        INPUT:
    30363036
    3037         - ``s`` -- source vertex
    3038         - ``t`` -- sink vertex
    3039         - ``value_only`` -- boolean (default: True). When set to
     3037        - ``s`` - source vertex
     3038        - ``t`` - sink vertex
     3039        - ``value_only`` - boolean (default: True). When set to
    30403040          True, only the weight of a minimum cut is returned.
    30413041          Otherwise, a list of edges of a minimum cut is also returned.
    3042         - ``use_edge_labels`` -- boolean (default: False). When set to
     3042        - ``use_edge_labels`` - boolean (default: False). When set to
    30433043          True, computes a weighted minimum cut where each edge has
    30443044          a weight defined by its label (if an edge has no label, `1`
    30453045          is assumed). Otherwise, each edge has weight `1`.
    3046         - ``vertices`` -- boolean (default: False). When set to True,
     3046        - ``vertices`` - boolean (default: False). When set to True,
    30473047          also returns the two sets of vertices that are disconnected by
    30483048          the cut. Implies ``value_only=False``.
    30493049
    30503050        OUTPUT:
    30513051
    3052         real number or tuple, depending on the arguments given
     3052        real number or tuple, depending on the given arguments
    30533053        (examples are given below)
    30543054
    30553055        EXAMPLES:
    class GenericGraph(GenericGraph_pyx): 
    30773077
    30783078        The two sides of the edge cut are obviously shorter paths::
    30793079
    3080            sage: value,edges,[set1,set2] = g.edge_cut(0, 14, use_edge_labels=True, vertices=True)  # optional - requires Glpk or COIN-OR/CBC
    3081            sage: g.subgraph(set1).is_isomorphic(graphs.PathGraph(len(set1)))                     # optional - requires Glpk or COIN-OR/CBC
    3082            True
    3083            sage: g.subgraph(set2).is_isomorphic(graphs.PathGraph(len(set2)))                     # optional - requires Glpk or COIN-OR/CBC
    3084            True
    3085            sage: len(set1) + len(set2) == g.order()                                                # optional - requires Glpk or COIN-OR/CBC
     3080           sage: value,edges,[set1,set2] = g.edge_cut(0, 14, use_edge_labels=True, vertices=True)  # optional - requires GLPK or COIN-OR/CBC
     3081           sage: g.subgraph(set1).is_isomorphic(graphs.PathGraph(len(set1))) # optional - requires GLPK or COIN-OR/CBC
     3082           True
     3083           sage: g.subgraph(set2).is_isomorphic(graphs.PathGraph(len(set2))) # optional - requires GLPK or COIN-OR/CBC
     3084           True
     3085           sage: len(set1) + len(set2) == g.order() # optional - requires GLPK or COIN-OR/CBC
    30863086           True
    30873087        """
    30883088        from sage.numerical.mip import MixedIntegerLinearProgram
    class GenericGraph(GenericGraph_pyx): 
    31603160       
    31613161        INPUT:
    31623162   
    3163         - ``value_only`` -- boolean (default: True). When set to
     3163        - ``value_only`` - boolean (default: True). When set to
    31643164          True, only the size of the minimum cut is returned
    3165         - ``vertices`` -- boolean (default: False). When set to
     3165        - ``vertices`` - boolean (default: False). When set to
    31663166          True, also returns the two sets of vertices that
    31673167          are disconnected by the cut. Implies ``value_only``
    31683168          set to False.
    31693169
    31703170        OUTPUT:
    31713171
    3172         real number or tuple, depending on the arguments given
     3172        real number or tuple, depending on the given arguments
    31733173        (examples are given below)
    31743174   
    31753175        EXAMPLE:
    31763176
    3177         A basic application in a Pappus graph::
     3177        A basic application in the Pappus graph::
    31783178       
    31793179           sage: g = graphs.PappusGraph()
    3180            sage: g.vertex_cut(1, 16, value_only=True) # optional - requires Glpk or COIN-OR/CBC
     3180           sage: g.vertex_cut(1, 16, value_only=True) # optional - requires GLPK or COIN-OR/CBC
    31813181           3.0
    31823182
    31833183        In the bipartite complete graph `K_{2,8}`, a cut between the two
    31843184        vertices in the size `2` part consists of the other `8` vertices::
    31853185
    31863186           sage: g = graphs.CompleteBipartiteGraph(2, 8)
    3187            sage: [value, vertices] = g.vertex_cut(0, 1, value_only=False) # optional - requires Glpk or COIN-OR/CBC
    3188            sage: print value # optional - requires Glpk or COIN-OR/CBC
     3187           sage: [value, vertices] = g.vertex_cut(0, 1, value_only=False) # optional - requires GLPK or COIN-OR/CBC
     3188           sage: print value # optional - requires GLPK or COIN-OR/CBC
    31893189           8.0
    3190            sage: vertices == range(2,10) # optional - requires Glpk or COIN-OR/CBC
     3190           sage: vertices == range(2,10) # optional - requires GLPK or COIN-OR/CBC
    31913191           True
    31923192
    31933193        Clearly, in this case the two sides of the cut are singletons ::
    31943194
    3195            sage: [value, vertices, [set1, set2]] = g.vertex_cut(0,1, vertices=True) # optional - requires Glpk or COIN-OR/CBC
    3196            sage: len(set1) == 1 # optional - requires Glpk or COIN-OR/CBC
    3197            True
    3198            sage: len(set2) == 1 # optional - requires Glpk or COIN-OR/CBC
     3195           sage: [value, vertices, [set1, set2]] = g.vertex_cut(0,1, vertices=True) # optional - requires GLPK or COIN-OR/CBC
     3196           sage: len(set1) == 1 # optional - requires GLPK or COIN-OR/CBC
     3197           True
     3198           sage: len(set2) == 1 # optional - requires GLPK or COIN-OR/CBC
    31993199           True
    32003200        """
    32013201        from sage.numerical.mip import MixedIntegerLinearProgram
    class GenericGraph(GenericGraph_pyx): 
    32643264        by a list of vertices.
    32653265       
    32663266        A minimum vertex cover of a graph is a set `S` of
    3267         its vertices such that each edge is incident to at least
     3267        vertices such that each edge is incident to at least
    32683268        one element of `S`, and such that `S` is of minimum
    32693269        cardinality.
    32703270        ( cf. http://en.wikipedia.org/wiki/Vertex_cover )
  • sage/graphs/graph.py

    diff --git a/sage/graphs/graph.py b/sage/graphs/graph.py
    a b class Graph(GenericGraph): 
    27372737
    27382738    def _gomory_hu_tree(self, vertices=None):
    27392739        r"""
    2740         Returns the Gomory-Hu tree associated to self (private function)
     2740        Returns a Gomory-Hu tree associated to self.
    27412741
    2742         This function is the privatre counterpart of ``gomory_hu_tree``,
    2743         with the difference that it accepts an optional argument
     2742        This function is the private counterpart of ``gomory_hu_tree()``,
     2743        with the difference that it has an optional argument
    27442744        needed for recursive computations, which the user is not
    2745         interested in defining by himself.
     2745        interested in defining himself.
    27462746
    2747         See the documentation of ``gomory_hu_tree`` for more information.
     2747        See the documentation of ``gomory_hu_tree()`` for more information.
    27482748
    27492749        INPUT:
    27502750
    2751         - ``vertices`` -- a set of ''real'' vertices, as opposed to the
     2751        - ``vertices`` - a set of "real" vertices, as opposed to the
    27522752          fakes one introduced during the computations. This variable is
    2753           useful for the algorithm, and I see no reason for the user to
    2754           change it.
     2753          useful for the algorithm and for recursion purposes.
    27552754
    27562755        EXAMPLE:
    27572756
    2758         This function is actually tested in ``gomory_hu_tree``, this
    2759         example is only present to have a doctest coverage of 100%
     2757        This function is actually tested in ``gomory_hu_tree()``, this
     2758        example is only present to have a doctest coverage of 100%.
    27602759
    27612760            sage: g = graphs.PetersenGraph()
    27622761            sage: t = g._gomory_hu_tree()      # optional - requires GLPK or CBC
    2763 
    27642762        """
    27652763        from sage.sets.set import Set
    27662764       
    class Graph(GenericGraph): 
    28002798        # Take any two vertices
    28012799        u,v = vertices[0:2]
    28022800
    2803         # flow = connectivity between u and v
    2804         # edges = min cut
    2805         # sets1, sets2 = the two sides of the edge cut
     2801        # Recovers the following values
     2802        # flow is the connectivity between u and v
     2803        # edges of a min cut
     2804        # sets1, sets2 are the two sides of the edge cut
    28062805        flow,edges,[set1,set2] = self.edge_cut(u, v, use_edge_labels=True, vertices=True)
    28072806
    28082807        # One graph for each part of the previous one
    class Graph(GenericGraph): 
    28562855
    28572856    def gomory_hu_tree(self):
    28582857        r"""
    2859         Returns the Gomory-Hu tree associated to self.
     2858        Returns a Gomory-Hu tree of self.
    28602859
    2861         Given a tree `T` with labelled edges representing capacities, it is very
     2860        Given a tree `T` with labeled edges representing capacities, it is very
    28622861        easy to determine the maximal flow between any pair of vertices :
    28632862        it is the minimal label on the edges of the unique path between them.
    28642863
    2865         Given a graph `G`, the Gomory-Hu tree `T` of `G`, is a tree
     2864        Given a graph `G`, a Gomory-Hu tree `T` of `G` is a tree
    28662865        with the same set of vertices, and such that the maximal flow
    2867         between any two vertices is the same in `G` and in `T`.
     2866        between any two vertices is the same in `G` as in `T`.
    28682867        (see http://en.wikipedia.org/wiki/Gomory%E2%80%93Hu_tree)
     2868        Note that, in general, a graph admits more than one Gomory-Hu
     2869        tree.
    28692870
    28702871        OUTPUT:
    28712872
    class Graph(GenericGraph): 
    28972898            sage: all([ t.flow(u,v) == g.flow(u,v) for u,v in Subsets( g.vertices(), 2 ) ]) # optional - requires GLPK or CBC
    28982899            True
    28992900
    2900         Just to make sure, let's check the same is true for two vertices
     2901        Just to make sure, we can check that the same is true for two vertices
    29012902        in a random graph::
    29022903
    29032904            sage: g = graphs.RandomGNP(20,.3)