# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1300023383 -28800
# Node ID 1b52b9e7ee13a28f36cb2282d28b85b165f6a1e2
# Parent 17a58011e11c6bb2fe64f3e03bbf0626ff684140
trac 10905 -- shortest path all pairs through BFS computations. (fixing doctests)
diff -r 17a58011e11c -r 1b52b9e7ee13 sage/graphs/base/c_graph.pyx
a
|
b
|
|
3086 | 3086 | sage: dist, path = all_pairs_shortest_path_BFS(g) |
3087 | 3087 | sage: all( dist[u][v] == g.distance(u,v) for u in g for v in g ) |
3088 | 3088 | True |
| 3089 | |
| 3090 | TESTS: |
| 3091 | |
| 3092 | Too large graphs:: |
| 3093 | |
| 3094 | sage: all_pairs_shortest_path_BFS(Graph(65536)) |
| 3095 | Traceback (most recent call last): |
| 3096 | ... |
| 3097 | ValueError: The graph backend contains more than 65535 nodes |
| 3098 | |
3089 | 3099 | """ |
3090 | 3100 | from sage.rings.infinity import Infinity |
3091 | 3101 | |
… |
… |
|
3095 | 3105 | cdef int n = max(vertices)+1 |
3096 | 3106 | |
3097 | 3107 | if n > <unsigned short> -1: |
3098 | | raise ValueError("The graph backend contains more than "+(<unsigned short> -1)+" nodes") |
| 3108 | raise ValueError("The graph backend contains more than "+str(<unsigned short> -1)+" nodes") |
3099 | 3109 | |
3100 | 3110 | # The vertices which have already been visited |
3101 | 3111 | cdef bitset_t seen |
diff -r 17a58011e11c -r 1b52b9e7ee13 sage/graphs/generic_graph.py
a
|
b
|
|
11063 | 11063 | ... p.insert(0,path[u][p[0]]) |
11064 | 11064 | sage: len(p) == dist[u][v] + 2 |
11065 | 11065 | True |
| 11066 | |
| 11067 | TESTS: |
| 11068 | |
| 11069 | Wrong name for ``algorithm``:: |
| 11070 | |
| 11071 | sage: g.shortest_path_all_pairs(algorithm="Bob") |
| 11072 | Traceback (most recent call last): |
| 11073 | ... |
| 11074 | ValueError: The algorithm keyword can only be set to "auto", "BFS", "Floyd-Warshall-Python" or "Floyd-Warshall-Cython" |
11066 | 11075 | """ |
11067 | 11076 | if default_weight != 1: |
11068 | 11077 | by_weight = True |
… |
… |
|
11085 | 11094 | raise ValueError("The algorithm keyword can only be set to "+ |
11086 | 11095 | "\"auto\","+ |
11087 | 11096 | " \"BFS\", "+ |
11088 | | "\"Floyd-Warshall-Cython\" or "+ |
| 11097 | "\"Floyd-Warshall-Python\" or "+ |
11089 | 11098 | "\"Floyd-Warshall-Cython\"") |
11090 | 11099 | |
11091 | 11100 | from sage.rings.infinity import Infinity |