Compare commits
2 commits
31c05c0f32
...
7c268e5739
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c268e5739 | ||
|
|
5ffa39c47b |
3 changed files with 52 additions and 1 deletions
38
src/ffalgo.ml
Normal file
38
src/ffalgo.ml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
open Graph
|
||||
open Printf
|
||||
open Tools
|
||||
|
||||
type 'a network = {
|
||||
graph: 'a graph;
|
||||
origin: id;
|
||||
destination: id;
|
||||
}
|
||||
|
||||
type flow = {
|
||||
current: int;
|
||||
capacity: int;
|
||||
}
|
||||
|
||||
type path = (id * id) list
|
||||
|
||||
(* int graph -> flow graph *)
|
||||
let initialize_graph gr = gmap gr (fun c -> { current = 0; capacity = c })
|
||||
|
||||
(* flow graph -> int graph *)
|
||||
let build_res_network gr = let gr_res = clone_nodes gr in
|
||||
e_fold gr (fun g origin destination fl ->
|
||||
let new_g = add_arc g origin destination (fl.capacity - fl.current) in
|
||||
add_arc new_g destination origin fl.current ) gr_res
|
||||
|
||||
(* int network -> path *)
|
||||
let find_path network = assert false
|
||||
|
||||
(* path -> int *)
|
||||
let find_min path = assert false
|
||||
|
||||
(* flow graph -> path -> aug -> flow graph *)
|
||||
let apply_path graph path aug = assert false
|
||||
|
||||
|
||||
let run_ff network = assert false
|
||||
|
||||
9
src/ffalgo.mli
Normal file
9
src/ffalgo.mli
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
open Graph
|
||||
|
||||
type 'a network = {
|
||||
graph: 'a graph;
|
||||
origin: int;
|
||||
destination: int;
|
||||
}
|
||||
|
||||
val run_ff: int network -> int
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
open Gfile
|
||||
open Tools
|
||||
open Ffalgo
|
||||
|
||||
let () =
|
||||
|
||||
|
|
@ -22,7 +24,9 @@ let () =
|
|||
|
||||
(* Open file *)
|
||||
let graph = from_file infile in
|
||||
|
||||
(* let graph2 = clone_nodes graph in *)
|
||||
(* let graph2 = gmap (gmap (gmap graph int_of_string) (fun x -> x + 1)) string_of_int in *)
|
||||
(* let graph2 = gmap (add_arc (gmap graph int_of_string) 2 1 13) string_of_int in *)
|
||||
(* Rewrite the graph that has been read. *)
|
||||
let () = export outfile graph in
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue