Add edge type data type
parent
a44e739b49
commit
ed655076ef
26
dfs.tidal
26
dfs.tidal
|
|
@ -8,6 +8,9 @@ import Data.List
|
||||||
|
|
||||||
import qualified Data.Array as A
|
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 :: Bounds -> [Vertex] -> Table Int
|
||||||
tabulate bnds vs = A.array bnds (zip vs [1..])
|
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 :: Graph -> [(Vertex,[Edge])]
|
||||||
nodeEdgePairs g = map (\u -> (u,[(u,v)| v <- g ! u])) $ preorderF $ dff g
|
nodeEdgePairs g = map (\u -> (u,[(u,v)| v <- g ! u])) $ preorderF $ dff g
|
||||||
--
|
--
|
||||||
instrument :: Graph -> Edge -> [Char]
|
edgeType :: Graph -> Edge -> EdgeType
|
||||||
instrument g e
|
edgeType g e@(x,y)
|
||||||
| p treeG = "clubkick"
|
| p treeG = T
|
||||||
| p forwardG = "superpwm"
|
| p forwardG = F
|
||||||
| p backG = "casio"
|
| p backG = B
|
||||||
| p crossG = "amencutup"
|
| p crossG = X
|
||||||
| otherwise = "sn" -- edge is (x,x)
|
| x == y = L
|
||||||
|
| otherwise = NE
|
||||||
where p f = e `elem` (f g)
|
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
|
-- complete graph
|
||||||
k n = buildG (1,n) [(u,v)|u <- [1..n],v <- [1..n]]
|
k n = buildG (1,n) [(u,v)|u <- [1..n],v <- [1..n]]
|
||||||
-- path
|
-- path
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue