aboutsummaryrefslogtreecommitdiff
path: root/bin/draw.hs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/draw.hs')
-rw-r--r--bin/draw.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/bin/draw.hs b/bin/draw.hs
index 4e19992..89658f6 100644
--- a/bin/draw.hs
+++ b/bin/draw.hs
@@ -1,18 +1,19 @@
{-# LANGUAGE ViewPatterns #-}
+
module Main where
-import Options.Applicative
+import Data.List
import Data.List.Split
import qualified Data.Map as M
-import Data.List
+import Options.Applicative
type Props = [[Double]]
+
type Nodes = [Int]
-- Command line args
data Options = Options
- {
- nthr :: Int,
+ { nthr :: Int,
propsPath :: FilePath,
clusterPath :: FilePath,
dotPath :: FilePath
@@ -25,10 +26,10 @@ data Tree = Tree [Double] Int [Tree]
children (Tree _ _ cs) = cs
addChild :: Tree -> Tree -> Tree
-(Tree a b cs) `addChild` child = Tree a b (child:cs)
+(Tree a b cs) `addChild` child = Tree a b (child : cs)
buildTree :: Props -> Nodes -> Tree
-buildTree (transpose -> ps) cl = merge n [Tree (ps !! i) (tab !! i) [] | i <- [0..n]]
+buildTree (transpose -> ps) cl = merge n [Tree (ps !! i) (tab !! i) [] | i <- [0 .. n]]
where
tab = tabulate cl
n = length tab - 1
@@ -38,7 +39,7 @@ buildTree (transpose -> ps) cl = merge n [Tree (ps !! i) (tab !! i) [] | i <- [0
merge 0 ts = head ts
merge i ts =
let j = parent i
- in merge (i-1) $ take j ts <> [(ts !! j) `addChild` (ts !! i)] <> drop (j+1) ts
+ in merge (i - 1) $ take j ts <> [(ts !! j) `addChild` (ts !! i)] <> drop (j + 1) ts
-- Prune a tree according to a node threshold
prune th = fix prune'