@Override public Node pickNode(final InferenceGraph g){
  treeCache.clear();
  Pair<List<Node>,Integer> bestPath=noPath;
  for (  Node n : g.nodes) {
    if (!Collections.disjoint(n.data,varsToSolve)) {
      Pair<List<Node>,Integer> path=computeTreeToLeafs(n);
      if (path.snd < bestPath.snd) {
        bestPath=path;
      }
    }
  }
  if (bestPath == noPath) {
    throw new NodeNotFoundException(g);
  }
  return bestPath.fst.head;
}

@ Override public Node pickNode ( final InferenceGraph g ) { treeCache . clear ( ) ; Pair < List < Node > , Integer > bestPath = noPath ; for ( Node n : g . nodes ) { if ( ! Collections . disjoint ( n . data , varsToSolve ) ) { Pair < List < Node > , Integer > path = computeTreeToLeafs ( n ) ; if ( path . snd < bestPath . snd ) { bestPath = path ; } } } if ( bestPath == noPath ) { throw new NodeNotFoundException ( g ) ; } return bestPath . fst . head ; }
pick the leaf that minimize cost
