2 * Copyright (C) 2013 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 | Leaf of int (* A single disk image (index of). *)
23 | Node of t list (* An interior node in the tree. *)
25 let rec images_in_subtree = function
27 | Node xs -> List.concat (List.map images_in_subtree xs)
29 let max_list = List.fold_left max min_int
32 let rec loop i = function
34 | x :: xs -> let r = f i x in r :: loop (i+1) xs
38 let format_cladogram ?format_leaf t =
39 let format_leaf = match format_leaf with
40 | None -> string_of_int
43 let rec format = function
45 let s = "--- " ^ format_leaf i in
46 [s; ""], String.length s
48 let xs = List.map format xs in
49 let n = List.length xs in
50 let w = 7 + max_list (List.map snd xs) in
53 let s, ss = match ss with
55 | [] -> assert false in
58 List.map (fun s -> " | " ^ s) ss
59 ) else if row < n-1 then (
61 List.map (fun s -> " | " ^ s) ss
64 List.map (fun s -> " " ^ s) ss
69 let strs, _ = format t in