2019-06-15 07:53:02 +03:00
|
|
|
module Data.Graph.Spec (spec) where
|
2018-10-31 19:20:38 +03:00
|
|
|
|
|
|
|
import SpecHelpers
|
|
|
|
|
2020-01-28 21:25:59 +03:00
|
|
|
import Data.Graph.Algebraic
|
2018-10-31 19:20:38 +03:00
|
|
|
import qualified Algebra.Graph.Class as Class
|
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
spec = describe "Data.Graph" $
|
|
|
|
it "has a valid topological sort" $ do
|
|
|
|
let topo = topologicalSort
|
|
|
|
topo (Class.path "ab") `shouldBe` "ba"
|
|
|
|
topo (Class.path "abc") `shouldBe` "cba"
|
|
|
|
topo ((vertex 'a' `connect` vertex 'b') `connect` vertex 'c') `shouldBe` "cba"
|
|
|
|
topo (vertex 'a' `connect` (vertex 'b' `connect` vertex 'c')) `shouldBe` "cba"
|
|
|
|
topo ((vertex 'a' `connect` vertex 'b') <> (vertex 'a' `connect` vertex 'c')) `shouldBe` "cba"
|
|
|
|
topo (Class.path "abd" <> Class.path "acd") `shouldBe` "dcba"
|
|
|
|
topo (Class.path "aba") `shouldBe` "ab"
|