Minimal cutset algorithm.