piDecomp :: (Floating prob, Ord prob, Ord a)
            => [String]
            -> [String]
            -> ModelDistribution prob a
            -> PILattice prob String
piDecomp s as m =
  let g  = piLattice as
      g' = nmap minimalInformation g
  in gmap (subtractLower g') g'
  where minimalInformation piN =
          piN { value = (nodeMinimalInformation s (partial piN) m)}
        subtractLower g' (inA, n, piN, outA) =
          (inA,
           n,
           piN { value = (value piN) -
                         (nodeMaxMinimalInformation s
                          (map (partial . snd) $ filter
                          (\(n',piN') -> (n',n) `elem` (edges g') ) $ labNodes g')
                          m )} ,
           outA)
piDecomp :: (Floating prob, Ord prob, Ord a)
            => [String]
            -> [String]
            -> ModelDistribution prob a
            -> PILattice prob String
piDecomp s as m =
  let g  = piLattice as
      g' = nmap minimalInformation g
  in gmap (subtractLower g') g'
  where minimalInformation piN =
          piN { value = (nodeMinimalInformation s (partial piN) m)}
        subtractLower g' (inA, n, piN, outA) =
          (inA,
           n,
           piN { value = (value piN) -
                         (nodeMaxMinimalInformation s
                          (map (partial . snd) $ filter
                          (\(n',piN') -> (n',n) `elem` (edges g') ) $ labNodes g')
                          m )} ,
           outA)
piDecomp s as m =
  let g  = piLattice as
      g' = nmap minimalInformation g
  in gmap (subtractLower g') g'
  where minimalInformation piN =
          piN { value = (nodeMinimalInformation s (partial piN) m)}
        subtractLower g' (inA, n, piN, outA) =
          (inA,
           n,
           piN { value = (value piN) -
                         (nodeMaxMinimalInformation s
                          (map (partial . snd) $ filter
                          (\(n',piN') -> (n',n) `elem` (edges g') ) $ labNodes g')
                          m )} ,
           outA)