This commit is contained in:
Baptiste 2024-12-02 18:11:06 +01:00
parent 71ab30c3bb
commit ed9ddb66ff
3 changed files with 7 additions and 5 deletions

View file

@ -34,10 +34,10 @@ let find_path (gr: 'a graph) (begin_node: id) (end_node: id) (filter: 'a arc ->
with
| Not_found -> []
let path_to_list s =
let numbers = List.map int_of_string (String.split_on_char ' ' s) in
let path_to_list numbers =
let rec build_pairs = function
| x :: (y :: _ as rest) -> (x, y) :: build_pairs rest
| _ -> []
in
build_pairs numbers
build_pairs numbers

View file

@ -7,4 +7,4 @@ val child_nodes: 'a graph -> id -> id list
val find_path: 'a graph -> id -> id -> ('a arc -> bool) -> id list
(* for example take [1;0;2;4] into [(1,0);(0,2);(2,4)]*)
val path_to_list: string -> (int * int) list
val path_to_list: int list -> (int * int) list

View file

@ -11,4 +11,6 @@ val add_arc: int graph -> id -> id -> int -> int graph
(* update_graph g l n : add n to all arcs in l. If an arc does not exist,it means that the arcs is in the otherside and the value is negative
raise Not_found if the arc does not exist in the graph *)
val update_graph: int graph -> (id*id) list -> int -> int graph
val update_graph: int graph -> (id*id) list -> int -> int graph
val take_min: int graph -> (id * id) list -> int -> int