Skip to content

Commit

Permalink
release 1.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
backtracking committed May 12, 2012
1 parent bae8c70 commit 14cd660
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

version 1.8.2, May 12, 2012
---------------------------
o new module [Path.BellmanFord] implementing Bellman-Ford algorithm
(contributed by Yuto Takei)
o new module Contraction implementing edge contraction
(contributed by Markus W. Weissmann)
o Gmap: new function [filter_map] (contributed by Markus W. Weissmann)
Expand Down
3 changes: 1 addition & 2 deletions src/path.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ struct

end

(* The following module is a contribution of Yuto Takei (University of Tokyo) *)

module BellmanFord
(G: G)
Expand All @@ -116,7 +117,6 @@ struct
let dist = H.create 97 in
H.add dist vs W.zero;
let admissible = H.create 97 in

let build_cycle_from x0 =
let rec traverse_parent x ret =
let e = H.find admissible x in
Expand All @@ -138,7 +138,6 @@ struct
in
visit x0
in

let rec relax i =
let update = G.fold_edges_e
(fun e x ->
Expand Down
21 changes: 12 additions & 9 deletions src/path.mli
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,32 @@ sig

end

(* The following module is a contribution of Yuto Takei (University of Tokyo) *)

module BellmanFord
(G: G)
(W: WEIGHT with type label = G.E.label) :
sig

module H : Hashtbl.S with type key = G.V.t (* and 'a t = W *)
module H : Hashtbl.S with type key = G.V.t

exception NegativeCycle of G.E.t list

val all_shortest_paths : G.t -> G.V.t -> W.t H.t
(** [shortest_path g vs] computes the distances of shortest paths from
vertex [vs] to all other vertices in graph [g]. They are returned as a
hash table mapping each vertex reachable from [vs] to its distance from [vs].
If [g] contains a negative-length cycle reachable from [vs],
raises [NegativeCycle l] where [l] is such a cycle.
(** [shortest_path g vs] computes the distances of shortest paths
from vertex [vs] to all other vertices in graph [g]. They are
returned as a hash table mapping each vertex reachable from
[vs] to its distance from [vs]. If [g] contains a
negative-length cycle reachable from [vs], raises
[NegativeCycle l] where [l] is such a cycle.
Complexity: at most O(VE) *)

val find_negative_cycle_from: G.t -> G.V.t -> G.E.t list
(** [find_negative_cycle_from g vs] looks for a negative-length cycle in graph [g]
that is reachable from vertex [vs] and returns it as a list of edges.
If no such a cycle exists, raises [Not_found].
(** [find_negative_cycle_from g vs] looks for a negative-length
cycle in graph [g] that is reachable from vertex [vs] and
returns it as a list of edges. If no such a cycle exists,
raises [Not_found].
Complexity: at most O(VE). *)

Expand Down

0 comments on commit 14cd660

Please sign in to comment.