|
69 | 69 |
|
70 | 70 | end
|
71 | 71 |
|
| 72 | +(* The following module is a contribution of Yuto Takei (University of Tokyo) *) |
72 | 73 |
|
73 | 74 | module BellmanFord
|
74 | 75 | (G: G)
|
75 | 76 | (W: WEIGHT with type label = G.E.label) :
|
76 | 77 | sig
|
77 | 78 |
|
78 |
| - module H : Hashtbl.S with type key = G.V.t (* and 'a t = W *) |
| 79 | + module H : Hashtbl.S with type key = G.V.t |
79 | 80 |
|
80 | 81 | exception NegativeCycle of G.E.t list
|
81 | 82 |
|
82 | 83 | val all_shortest_paths : G.t -> G.V.t -> W.t H.t
|
83 |
| - (** [shortest_path g vs] computes the distances of shortest paths from |
84 |
| - vertex [vs] to all other vertices in graph [g]. They are returned as a |
85 |
| - hash table mapping each vertex reachable from [vs] to its distance from [vs]. |
86 |
| - If [g] contains a negative-length cycle reachable from [vs], |
87 |
| - raises [NegativeCycle l] where [l] is such a cycle. |
| 84 | + (** [shortest_path g vs] computes the distances of shortest paths |
| 85 | + from vertex [vs] to all other vertices in graph [g]. They are |
| 86 | + returned as a hash table mapping each vertex reachable from |
| 87 | + [vs] to its distance from [vs]. If [g] contains a |
| 88 | + negative-length cycle reachable from [vs], raises |
| 89 | + [NegativeCycle l] where [l] is such a cycle. |
88 | 90 |
|
89 | 91 | Complexity: at most O(VE) *)
|
90 | 92 |
|
91 | 93 | val find_negative_cycle_from: G.t -> G.V.t -> G.E.t list
|
92 |
| - (** [find_negative_cycle_from g vs] looks for a negative-length cycle in graph [g] |
93 |
| - that is reachable from vertex [vs] and returns it as a list of edges. |
94 |
| - If no such a cycle exists, raises [Not_found]. |
| 94 | + (** [find_negative_cycle_from g vs] looks for a negative-length |
| 95 | + cycle in graph [g] that is reachable from vertex [vs] and |
| 96 | + returns it as a list of edges. If no such a cycle exists, |
| 97 | + raises [Not_found]. |
95 | 98 |
|
96 | 99 | Complexity: at most O(VE). *)
|
97 | 100 |
|
|
0 commit comments