diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-12-17 11:37:54 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-12-17 11:37:54 +0100 |
commit | 1e5b58007da3be94755b017004cd5fe484ccbed7 (patch) | |
tree | 0b285c48f3151add05cf7c8dfbb960646c7df49f /sched/graph.ml | |
parent | f91d7484c8d5af62dff97eb9ce5a5ac85aba2005 (diff) | |
download | SystDigit-Projet-1e5b58007da3be94755b017004cd5fe484ccbed7.tar.gz SystDigit-Projet-1e5b58007da3be94755b017004cd5fe484ccbed7.zip |
Tabs to spaces ; deleted Caml simulator (useless anyways)
Diffstat (limited to 'sched/graph.ml')
-rw-r--r-- | sched/graph.ml | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/sched/graph.ml b/sched/graph.ml index 08762a1..d5f34a9 100644 --- a/sched/graph.ml +++ b/sched/graph.ml @@ -32,29 +32,29 @@ let find_roots g = List.filter (fun n -> n.n_linked_by = []) g.g_nodes let has_cycle g = - clear_marks g; - let rec visit n = - match n.n_mark with - | InProgress -> true - | Visited -> false - | NotVisited -> - n.n_mark <- InProgress; - let ret = List.fold_left (fun x n -> x || (visit n)) false n.n_link_to in - n.n_mark <- Visited; - ret - in - let ret = List.fold_left (fun x n -> x || (if n.n_mark = Visited then false else visit n)) false g.g_nodes - in clear_marks g; ret + clear_marks g; + let rec visit n = + match n.n_mark with + | InProgress -> true + | Visited -> false + | NotVisited -> + n.n_mark <- InProgress; + let ret = List.fold_left (fun x n -> x || (visit n)) false n.n_link_to in + n.n_mark <- Visited; + ret + in + let ret = List.fold_left (fun x n -> x || (if n.n_mark = Visited then false else visit n)) false g.g_nodes + in clear_marks g; ret let topological g = - clear_marks g; - let rec aux acc n = - if n.n_mark = Visited - then acc - else begin - n.n_mark <- Visited; - n.n_label :: (List.fold_left (fun x n -> aux x n) acc n.n_linked_by) - end - in - let ret = List.fold_left (fun x n -> aux x n) [] g.g_nodes - in clear_marks g; List.rev ret + clear_marks g; + let rec aux acc n = + if n.n_mark = Visited + then acc + else begin + n.n_mark <- Visited; + n.n_label :: (List.fold_left (fun x n -> aux x n) acc n.n_linked_by) + end + in + let ret = List.fold_left (fun x n -> aux x n) [] g.g_nodes + in clear_marks g; List.rev ret |