From ed655076eff767abef075cee70a1250ad8b781d0 Mon Sep 17 00:00:00 2001 From: loooph Date: Wed, 1 Mar 2023 00:12:44 +0100 Subject: [PATCH] Add edge type data type --- dfs.tidal | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/dfs.tidal b/dfs.tidal index fdeb72f..7ddcd39 100644 --- a/dfs.tidal +++ b/dfs.tidal @@ -8,6 +8,9 @@ import Data.List import qualified Data.Array as A +-- Tree, Forward, Back, Cross, Loop, No Edge +data EdgeType = T | F | B | X | L | NE deriving Show +-- tabulate :: Bounds -> [Vertex] -> Table Int tabulate bnds vs = A.array bnds (zip vs [1..]) -- @@ -51,15 +54,24 @@ pairfastcat = (\(u,v) -> fastcat $ pure <$> [u,v]) nodeEdgePairs :: Graph -> [(Vertex,[Edge])] nodeEdgePairs g = map (\u -> (u,[(u,v)| v <- g ! u])) $ preorderF $ dff g -- -instrument :: Graph -> Edge -> [Char] -instrument g e - | p treeG = "clubkick" - | p forwardG = "superpwm" - | p backG = "casio" - | p crossG = "amencutup" - | otherwise = "sn" -- edge is (x,x) +edgeType :: Graph -> Edge -> EdgeType +edgeType g e@(x,y) + | p treeG = T + | p forwardG = F + | p backG = B + | p crossG = X + | x == y = L + | otherwise = NE where p f = e `elem` (f g) -- +instrument :: Graph -> Edge -> [Char] +instrument g e = case edgeType g e of + T -> "clubkick" + F -> "superpwm" + B -> "casio" + X -> "amencutup" + L -> "sn" + NE -> " " -- let super collider deal with it -- complete graph k n = buildG (1,n) [(u,v)|u <- [1..n],v <- [1..n]] -- path