aboutsummaryrefslogtreecommitdiffstats
path: root/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/Main.hs b/src/Main.hs
index aabff1c..ffbef9a 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -40,14 +40,19 @@ eval (Node Xor c1 c2) = eval c1 `xor` eval c2
eval (Node Nand c1 c2) = complement $ eval c1 .&. eval c2
eval (Node Nor c1 c2) = complement $ eval c1 .|. eval c2
-visualize :: (Show a) => Circuit a -> Gr String ()
+visualize :: (Show a) => Circuit a -> Gr String String
visualize circ =
uncurry mkGraph $ graph Nothing 0 ([], []) circ
where
- graph (Just (par, _)) nl (n, e) (In val) = (n ++ [(nl, "In: " ++ show val)], e ++ [(par, nl, ())])
- graph Nothing nl (n, e) (In val) = (n ++ [(nl, "In: " ++ show val)], e)
- graph _ _ _ _ = ([], [])
+ graph parent nl (l, e) circ =
+ case (parent, circ) of
+ (Nothing, (In val)) ->
+ ((nl, "In: " ++ show val) : l, e)
+ (Just par, (In val)) ->
+ ((nl, "In: " ++ show val) : l, (par, nl, "") : e)
+ _ ->
+ ([], [])
main :: IO ()
--main = sample (arbitrary :: Gen (Circuit Input))
-main = putStrLn . unpack . renderDot . toDot . graphToDot nonClusteredParams $ visualize (In True)
+main = preview $ visualize (In True)