The junction tree algorithm