Add edge type data type

master
loooph 2023-03-01 00:12:44 +01:00
parent a44e739b49
commit ed655076ef
1 changed files with 19 additions and 7 deletions

View File

@ -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