# 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
|
|
2137 | 2137 | |
2138 | 2138 | # these values are possibly the infinity !!!! |
2139 | 2139 | |
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 |
2141 | 2141 | start_complement = start(start_complement) if start_complement <= self.order() else self.order()+2 |
2142 | | |
| 2142 | |
2143 | 2143 | counter_example = None |
2144 | 2144 | |
2145 | 2145 | for i in range(min(start_self, start_complement), self.order()+1,2): |
… |
… |
|
2147 | 2147 | # trying in self |
2148 | 2148 | if i >= start_self: |
2149 | 2149 | counter_example = self.subgraph_search(graphs.CycleGraph(i), induced = True) |
2150 | | |
| 2150 | |
2151 | 2151 | if counter_example is not None: |
2152 | 2152 | break |
2153 | 2153 | |
… |
… |
|
2163 | 2163 | else: |
2164 | 2164 | return counter_example is None |
2165 | 2165 | |
2166 | | def is_strongly_regular(self, return_parameters=False): |
| 2166 | def is_strongly_regular(self, parameters=False): |
2167 | 2167 | r""" |
2168 | 2168 | Tests whether ``self`` is strongly regular. |
2169 | 2169 | |
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. |
2174 | 2176 | |
2175 | 2177 | * Any two adjacent vertices of `G` have `\lambda` common neighbors. |
2176 | 2178 | |
… |
… |
|
2178 | 2180 | |
2179 | 2181 | INPUT: |
2180 | 2182 | |
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. |
2186 | 2188 | |
2187 | 2189 | EXAMPLES: |
2188 | 2190 | |
… |
… |
|
2191 | 2193 | sage: g = graphs.PetersenGraph() |
2192 | 2194 | sage: g.is_strongly_regular() |
2193 | 2195 | 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) |
2196 | 2198 | |
2197 | 2199 | And Clebsch's graph is too:: |
2198 | 2200 | |
2199 | 2201 | sage: g = graphs.ClebschGraph() |
2200 | 2202 | sage: g.is_strongly_regular() |
2201 | 2203 | 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) |
2204 | 2206 | |
2205 | 2207 | But Chvatal's graph is not:: |
2206 | 2208 | |
… |
… |
|
2242 | 2244 | if m != inter: |
2243 | 2245 | return False |
2244 | 2246 | |
2245 | | if return_parameters: |
2246 | | return (k,l,m) |
| 2247 | if parameters: |
| 2248 | return (self.order(),k,l,m) |
2247 | 2249 | else: |
2248 | 2250 | return True |
2249 | 2251 | |
diff --git a/sage/graphs/graph_coloring.py b/sage/graphs/graph_coloring.py
a
|
b
|
|
225 | 225 | """ |
226 | 226 | #Take care of the stupid stuff |
227 | 227 | if n == 1: |
228 | | return int(len(G.edges()) == 0) |
| 228 | return int(G.size() == 0) |
229 | 229 | if n < 1: |
230 | 230 | if n == 0: |
231 | | return int(len(G.vertices()) == 0) |
| 231 | return int(G.order() == 0) |
232 | 232 | else: |
233 | 233 | #negative colors?? what does that even mean? |
234 | 234 | return 0 |
… |
… |
|
272 | 272 | o = G.order() |
273 | 273 | if o == 0: |
274 | 274 | return 0 |
275 | | if len(G.edges()) == 0: |
| 275 | if G.size() == 0: |
276 | 276 | return 1 |
277 | 277 | elif G.is_bipartite(): #can we do it in linear time? |
278 | 278 | return 2 |
diff --git a/sage/graphs/spanning_tree.pyx b/sage/graphs/spanning_tree.pyx
a
|
b
|
|
6 | 6 | [JoynerNguyenCohen2010]_ for descriptions of spanning tree algorithms, |
7 | 7 | including minimum spanning trees. |
8 | 8 | |
| 9 | .. SEEALSO:: |
| 10 | |
| 11 | * :meth:`GenericGraph.min_spanning_tree |
| 12 | <sage.graphs.generic_graph.GenericGraph.min_spanning_tree>`. |
| 13 | |
9 | 14 | **Todo** |
10 | 15 | |
11 | 16 | * Rewrite :func:`kruskal` to use priority queues. Once Cython has support |