feat: path_to_list
This commit is contained in:
parent
89139ffe3c
commit
bc89f7bcf5
2 changed files with 13 additions and 2 deletions
|
|
@ -32,4 +32,12 @@ let find_path (gr: 'a graph) (begin_node: id) (end_node: id) (filter: 'a arc ->
|
|||
try
|
||||
find_way begin_node [begin_node]
|
||||
with
|
||||
| Not_found -> [];
|
||||
| Not_found -> []
|
||||
|
||||
let path_to_list s =
|
||||
let numbers = List.map int_of_string (String.split_on_char ' ' s) in
|
||||
let rec build_pairs = function
|
||||
| x :: (y :: _ as rest) -> (x, y) :: build_pairs rest
|
||||
| _ -> []
|
||||
in
|
||||
build_pairs numbers
|
||||
|
|
@ -4,4 +4,7 @@ open Graph
|
|||
val child_nodes: 'a graph -> id -> id list
|
||||
|
||||
(* search path between 2 node and return the path : a list of node *)
|
||||
val find_path: 'a graph -> id -> id -> ('a arc -> bool) -> 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
|
||||
Loading…
Reference in a new issue