updateGraph :: (Ord a, Ord c) => DepGraph a b c -> a -> b -> DepGraph a b c
updateGraph gr key val =
    -- update the pred-set of all smaller entries
    let (mOv, nm) = Map.insertLookupWithKey f key nval $ dataMap gr
        npl = getPredecessors gr key val
        nval = (val, Set.empty, Set.fromList npl)
        f _ (v', _, nps) (_, oss, _) = (v', oss, nps)
        nm' = case mOv of
                Just (_, _, ops) ->
                    Set.fold rmFromSucc nm ops
                _ -> nm
        rmFromSucc c = Map.adjust g1 (getKey gr c)
        g1 (x, dss, dps) = (x, Set.delete key dss, dps)
        nm'' = foldl insSucc nm' npl
        insSucc m c = Map.adjust g2 (getKey gr c) m
        g2 (x, dss, dps) = (x, Set.insert key dss, dps)
    in gr { dataMap = nm'' }
updateGraph :: (Ord a, Ord c) => DepGraph a b c -> a -> b -> DepGraph a b c
updateGraph gr key val =
    -- update the pred-set of all smaller entries
    let (mOv, nm) = Map.insertLookupWithKey f key nval $ dataMap gr
        npl = getPredecessors gr key val
        nval = (val, Set.empty, Set.fromList npl)
        f _ (v', _, nps) (_, oss, _) = (v', oss, nps)
        nm' = case mOv of
                Just (_, _, ops) ->
                    Set.fold rmFromSucc nm ops
                _ -> nm
        rmFromSucc c = Map.adjust g1 (getKey gr c)
        g1 (x, dss, dps) = (x, Set.delete key dss, dps)
        nm'' = foldl insSucc nm' npl
        insSucc m c = Map.adjust g2 (getKey gr c) m
        g2 (x, dss, dps) = (x, Set.insert key dss, dps)
    in gr { dataMap = nm'' }
updateGraph gr key val =
    -- update the pred-set of all smaller entries
    let (mOv, nm) = Map.insertLookupWithKey f key nval $ dataMap gr
        npl = getPredecessors gr key val
        nval = (val, Set.empty, Set.fromList npl)
        f _ (v', _, nps) (_, oss, _) = (v', oss, nps)
        nm' = case mOv of
                Just (_, _, ops) ->
                    Set.fold rmFromSucc nm ops
                _ -> nm
        rmFromSucc c = Map.adjust g1 (getKey gr c)
        g1 (x, dss, dps) = (x, Set.delete key dss, dps)
        nm'' = foldl insSucc nm' npl
        insSucc m c = Map.adjust g2 (getKey gr c) m
        g2 (x, dss, dps) = (x, Set.insert key dss, dps)
    in gr { dataMap = nm'' }