More graph theory

Computing with Alga

writing in progress, check back later.

Mirroring the code examples from Basic graph theory in Haskell...

import           Algebra.Graph

trivialAndEmpty :: Graph Char
trivialAndEmpty = vertex 'a'

nonTrivial :: Graph Char
nonTrivial = edge 'a' 'b'

denserGraph :: Graph Char
denserGraph
  = edges [ ('a', 'b'), ('b', 'c'), ('a', 'c') ]
  `overlay` vertex 'd'

test :: IO ()
test = do
  print $ edgeCount trivialAndEmpty == 0
  print $ vertexCount trivialAndEmpty == 1
  print $ hasEdge 'a' 'b' nonTrivial
  print $ vertexList denserGraph == ['a', 'b', 'c', 'd']
  print $ edgeList denserGraph == [('a','b'),('a','c'),('b','c')]
  print $ (path "abc" `overlay` path "ac") `overlay` vertex 'd' == denserGraph

To be continued...

<< back