Ticket #13510: trac_13510.patch

File trac_13510.patch, 4.7 KB (added by ncohen, 8 years ago)
  • sage/graphs/graph.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1348094921 -7200
    # Node ID 36faf5fb036fee07585fa336adfed89983312962
    # Parent  1b1a2f0434bb3b8319fac8578f5669861a6a4a1e
    Small change to graph_is_strongly_regular (return the number of vertices)
    
    diff --git a/sage/graphs/graph.py b/sage/graphs/graph.py
    a b  
    21372137
    21382138        # these values are possibly the infinity !!!!
    21392139
    2140         start_self = start(start_self) if start_self <= self.order() else self.order()+2 
     2140        start_self = start(start_self) if start_self <= self.order() else self.order()+2
    21412141        start_complement = start(start_complement) if start_complement <= self.order() else self.order()+2
    2142            
     2142
    21432143        counter_example = None
    21442144
    21452145        for i in range(min(start_self, start_complement), self.order()+1,2):
     
    21472147            # trying in self
    21482148            if i >= start_self:
    21492149                counter_example = self.subgraph_search(graphs.CycleGraph(i), induced = True)
    2150                
     2150
    21512151                if counter_example is not None:
    21522152                    break
    21532153
     
    21632163        else:
    21642164            return counter_example is None
    21652165
    2166     def is_strongly_regular(self, return_parameters=False):
     2166    def is_strongly_regular(self, parameters=False):
    21672167        r"""
    21682168        Tests whether ``self`` is strongly regular.
    21692169
    2170         A graph `G` is said to be strongly regular with parameters `(k, \lambda,
    2171         \mu)` if and only if:
    2172 
    2173             * `G` is `k`-regular
     2170        A graph `G` is said to be strongly regular with parameters (n, k,
     2171        \lambda, \mu)` if and only if:
     2172
     2173            * `G` has `n` vertices.
     2174
     2175            * `G` is `k`-regular.
    21742176
    21752177            * Any two adjacent vertices of `G` have `\lambda` common neighbors.
    21762178
     
    21782180
    21792181        INPUT:
    21802182
    2181         - ``return_parameters`` (boolean) -- whether to return the triple
    2182           `(k,\lambda,\mu)`. If ``return_parameters = False`` (default), this
    2183           method only returns ``True`` and ``False`` answers. If
    2184           ``return_parameters=True``, the ``True`` answers are replaced by
    2185           triples `(k,\lambda,\mu)`. See definition above.
     2183        - ``parameters`` (boolean) -- whether to return the quadruple `(n,
     2184          k,\lambda,\mu)`. If ``parameters = False`` (default), this method only
     2185          returns ``True`` and ``False`` answers. If ``parameters=True``, the
     2186          ``True`` answers are replaced by quadruples `(n, k,\lambda,\mu)`. See
     2187          definition above.
    21862188
    21872189        EXAMPLES:
    21882190
     
    21912193            sage: g = graphs.PetersenGraph()
    21922194            sage: g.is_strongly_regular()
    21932195            True
    2194             sage: g.is_strongly_regular(return_parameters = True)
    2195             (3, 0, 1)
     2196            sage: g.is_strongly_regular(parameters = True)
     2197            (10, 3, 0, 1)
    21962198
    21972199        And Clebsch's graph is too::
    21982200
    21992201            sage: g = graphs.ClebschGraph()
    22002202            sage: g.is_strongly_regular()
    22012203            True
    2202             sage: g.is_strongly_regular(return_parameters = True)
    2203             (5, 0, 2)
     2204            sage: g.is_strongly_regular(parameters = True)
     2205            (16, 5, 0, 2)
    22042206
    22052207        But Chvatal's graph is not::
    22062208
     
    22422244                            if m != inter:
    22432245                                return False
    22442246
    2245             if return_parameters:
    2246                 return (k,l,m)
     2247            if parameters:
     2248                return (self.order(),k,l,m)
    22472249            else:
    22482250                return True
    22492251
  • sage/graphs/graph_coloring.py

    diff --git a/sage/graphs/graph_coloring.py b/sage/graphs/graph_coloring.py
    a b  
    225225    """
    226226    #Take care of the stupid stuff
    227227    if n == 1:
    228         return int(len(G.edges()) == 0)
     228        return int(G.size() == 0)
    229229    if n < 1:
    230230        if n == 0:
    231             return int(len(G.vertices()) == 0)
     231            return int(G.order() == 0)
    232232        else:
    233233            #negative colors?? what does that even mean?
    234234            return 0
     
    272272    o = G.order()
    273273    if o == 0:
    274274        return 0
    275     if len(G.edges()) == 0:
     275    if G.size() == 0:
    276276        return 1
    277277    elif G.is_bipartite(): #can we do it in linear time?
    278278        return 2
  • sage/graphs/spanning_tree.pyx

    diff --git a/sage/graphs/spanning_tree.pyx b/sage/graphs/spanning_tree.pyx
    a b  
    66[JoynerNguyenCohen2010]_ for descriptions of spanning tree algorithms,
    77including minimum spanning trees.
    88
     9.. SEEALSO::
     10
     11   * :meth:`GenericGraph.min_spanning_tree
     12     <sage.graphs.generic_graph.GenericGraph.min_spanning_tree>`.
     13
    914**Todo**
    1015
    1116* Rewrite :func:`kruskal` to use priority queues. Once Cython has support