Skip to content

Instantly share code, notes, and snippets.

@schickling
Created October 24, 2013 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schickling/7132994 to your computer and use it in GitHub Desktop.
Save schickling/7132994 to your computer and use it in GitHub Desktop.
data Tree = Branch [Tree]
deriving Show
{- first int is the min cover; second int is the min cover that includes the root -}
minVC :: Tree -> (Int, Int)
minVC (Branch subtrees) = let
costs = map minVC subtrees
minWithRoot = 1 + sum (map fst costs) in
(min minWithRoot (sum (map snd costs)), minWithRoot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment