What is a good algorithm for getting the minimum vertex cover of a tree?

后端 未结 7 561
感动是毒
感动是毒 2020-12-28 16:55

What is a good algorithm for getting the minimum vertex cover of a tree?

INPUT:

The node\'s neighbours.

OUTPUT:

The minimum number of vertice

相关标签:
7条回答
  • 2020-12-28 17:18
    {- Haskell implementation of Artem's algorithm -}
    
    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)
    
    0 讨论(0)
提交回复
热议问题