aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-10-29 11:45:58 +0000
committerYann Herklotz <ymherklotz@gmail.com>2018-10-29 11:45:58 +0000
commit485f6ed3c4c9814e6e1aef9d79930c0f97580fb8 (patch)
tree15428066f7d7687f9e992d53247769347b750478 /src
parentdf7d0f93d38f229ea6cdd8e391480c3f5b085af5 (diff)
downloadverismith-485f6ed3c4c9814e6e1aef9d79930c0f97580fb8.tar.gz
verismith-485f6ed3c4c9814e6e1aef9d79930c0f97580fb8.zip
Broken change rendering the graph
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 0d49a3c..529c5b0 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -1,7 +1,12 @@
module Main where
import Data.Bits
-import Test.QuickCheck hiding ((.&.), (.|.))
+import Test.QuickCheck hiding ((.&.))
+import Data.GraphViz
+import Data.Graph.Inductive.Example (clr479, dag4)
+import Data.Text.Lazy
+import Data.GraphViz.Printing
+import Data.Graph.Inductive.Graph
type Input = Bool
@@ -34,5 +39,14 @@ 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 :: (Graph g, Show a) => Circuit a -> g 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 _ _ _ _ = ([], [])
+
main :: IO ()
-main = sample (arbitrary :: Gen (Circuit Input))
+--main = sample (arbitrary :: Gen (Circuit Input))
+main = putStrLn . unpack . renderDot . toDot . graphToDot nonClusteredParams $ visualize (In True)