Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #27859: add test on random digraphs
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoudert committed Aug 3, 2019
1 parent 7c9bc30 commit 3ae912d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/sage/graphs/path_enumeration.pyx
Expand Up @@ -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))
Expand Down

0 comments on commit 3ae912d

Please sign in to comment.