Ticket #14536: trac_14536_review1.patch

File trac_14536_review1.patch, 2.7 KB (added by chapoton, 8 years ago)
  • sage/graphs/digraph_generators.py

    # HG changeset patch
    # User Frederic Chapoton <chapoton at math.univ-lyon1.fr>
    # Date 1369336817 -7200
    # Node ID 0e2c6444bfaec476a9ee79d484b4d5f8f5daea17
    # Parent  d7db781e12ff5cee873be1d5da9f75cfb37da415
    trac #14536 review patch
    
    diff --git a/sage/graphs/digraph_generators.py b/sage/graphs/digraph_generators.py
    a b class DiGraphGenerators(): 
    317317        g.set_pos({i:(i,0) for i in range(n)})
    318318        return g
    319319
    320     def TransitiveTournament(self,n):
     320    def TransitiveTournament(self, n):
    321321        r"""
    322322        Returns a transitive tournament on `n` vertices.
    323323
    324324        In this tournament there is an edge from `i` to `j` if `i<j`.
    325325
     326        See :wikipedia:`Tournament (graph theory)`
     327
    326328        INPUT:
    327329
    328330        - ``n`` (integer) -- number of vertices in the tournament.
    class DiGraphGenerators(): 
    349351
    350352        for i in range(n-1):
    351353            for j in range(i+1, n):
    352                 g.add_edge(i,j)
     354                g.add_edge(i, j)
    353355
    354356        if n:
    355357            from sage.graphs.graph_plot import _circle_embedding
    class DiGraphGenerators(): 
    357359
    358360        return g
    359361
    360     def RandomTournament(self,n):
     362    def RandomTournament(self, n):
    361363        r"""
    362364        Returns a random tournament on `n` vertices.
    363365
    364         The tournament returned has an edge from `i` to `j` with probability
    365         `1/2`.
     366        For every pair of vertices, the tournament has an edge from
     367        `i` to `j` with probability `1/2`, otherwise it has an edge
     368        from `j` to `i`.
     369
     370        See :wikipedia:`Tournament (graph theory)`
    366371
    367372        INPUT:
    368373
    class DiGraphGenerators(): 
    370375
    371376        EXAMPLES::
    372377
    373             sage: digraphs.RandomTournament(10)
     378            sage: T = digraphs.RandomTournament(10); T
    374379            Random Tournament: Digraph on 10 vertices
     380            sage: T.size() == binomial(10, 2)
     381            True
    375382            sage: digraphs.RandomTournament(-1)
    376383            Traceback (most recent call last):
    377384            ...
    class DiGraphGenerators(): 
    383390
    384391        for i in range(n-1):
    385392            for j in range(i+1, n):
    386                 if random()<=.5:
    387                     g.add_edge(i,j)
     393                if random() <= .5:
     394                    g.add_edge(i, j)
    388395                else:
    389                     g.add_edge(j,i)
     396                    g.add_edge(j, i)
    390397
    391398        if n:
    392399            from sage.graphs.graph_plot import _circle_embedding
    class DiGraphGenerators(): 
    482489
    483490                if j == n-1:
    484491                    i += 1
    485                     j  = i+1
     492                    j = i+1
    486493                else:
    487494                    j += 1
    488495