Per-edge caching of log-likelihoods