diff --git a/src/sage/graphs/path_enumeration.pyx b/src/sage/graphs/path_enumeration.pyx index 1fa428a0b58..a48402c52e1 100644 --- a/src/sage/graphs/path_enumeration.pyx +++ b/src/sage/graphs/path_enumeration.pyx @@ -500,6 +500,23 @@ def shortest_simple_paths(self, source, target, weight_function=None, sage: s == t True + Check that "Yen" and "Feng" provide same results on random digraphs:: + + sage: G = digraphs.RandomDirectedGNP(30, .05) + sage: while not G.is_strongly_connected(): + ....: G = digraphs.RandomDirectedGNP(30, .1) + sage: for u, v in list(G.edges(labels=False, sort=False)): + ....: G.set_edge_label(u, v, randint(1, 10)) + sage: V = G.vertices() + sage: shuffle(V) + sage: u, v = V[:2] + sage: it_Y = G.shortest_simple_paths(u, v, by_weight=True, report_weight=True, algorithm='Yen') + sage: it_F = G.shortest_simple_paths(u, v, by_weight=True, report_weight=True, algorithm='Feng') + sage: for i, (y, f) in enumerate(zip(it_Y, it_F)): + ....: if y[0] != f[0]: + ....: raise ValueError("something goes wrong !") + ....: if i == 100: + ....: break """ if source not in self: raise ValueError("vertex '{}' is not in the graph".format(source))