From 74142977d97cba3ad092e5661225dccc08b105b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9onie=20Gallois?= Date: Sun, 15 Nov 2020 09:35:02 +0100 Subject: [PATCH] blf et get_path --- src/BLF.ml | 21 +++++++++++---------- src/BLF.mli | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/BLF.ml b/src/BLF.ml index d41ae5c..d4391c9 100644 --- a/src/BLF.ml +++ b/src/BLF.ml @@ -6,17 +6,17 @@ type t_cost={ mutable father:int } -let blf gr= +let blf gr id_src id_dest= (*je compte le nb de noeuds dans le graphe pour instancier mon tableau*) let nb_n=n_fold gr (fun acu id->acu+1) 0 in - let cost ={cout=max_int; father=0} in + let cost ={cout=max_int; father=(-1)} in let acu =Array.make nb_n cost in (*je fais un fold_left pour pouvoir individualiser au niveau de la mémoire les cases de la table*) - let blf_tab=n_fold gr (fun acu id->acu.(id)<-{cout=max_int; father=0}; acu ) acu in + let blf_tab=n_fold gr (fun acu id->acu.(id)<-{cout=max_int; father=(-1)}; acu ) acu in - let file_id=[0] in + let file_id=[id_src] in let rec blf_rec gr file_id = match file_id with |[]-> blf_tab @@ -25,7 +25,7 @@ let blf gr= let rec loop_suc file_id l_out_arc blf_tab=match l_out_arc with |[]-> blf_rec gr b |(id,label)::d-> - if (blf_tab.(a).cout+label)(0::path) - |a->loop (a::path) blf_tab a in - loop path blf_tab id_dest + |(-1)->None + |a->if a == id_src then Some (id_src::path) else loop (a::path) blf_tab id_src a in + loop path blf_tab id_src id_dest diff --git a/src/BLF.mli b/src/BLF.mli index a78afa8..54861d8 100644 --- a/src/BLF.mli +++ b/src/BLF.mli @@ -5,6 +5,6 @@ type t_cost={ mutable father:int } -val blf: int graph -> t_cost array +val blf: int graph -> id -> id -> t_cost array -val get_path: t_cost array -> int -> int list \ No newline at end of file +val get_path: int graph -> id -> id -> int list option \ No newline at end of file