public static void viterbiWalk(final HGNode node,final WalkerFunction walker,final int nodeIndex){
  walker.apply(node,nodeIndex);
  final HyperEdge bestEdge=node.bestHyperedge;
  final List<HGNode> tailNodes=bestEdge.getTailNodes();
  if (tailNodes != null) {
    for (int tailNodeIndex=0; tailNodeIndex < tailNodes.size(); tailNodeIndex++) {
      viterbiWalk(tailNodes.get(tailNodeIndex),walker,tailNodeIndex);
    }
  }
}

public static void viterbiWalk ( final HGNode node , final WalkerFunction walker , final int nodeIndex ) { walker . apply ( node , nodeIndex ) ; final HyperEdge bestEdge = node . bestHyperedge ; final List < HGNode > tailNodes = bestEdge . getTailNodes ( ) ; if ( tailNodes != null ) { for ( int tailNodeIndex = 0 ; tailNodeIndex < tailNodes . size ( ) ; tailNodeIndex ++ ) { viterbiWalk ( tailNodes . get ( tailNodeIndex ) , walker , tailNodeIndex ) ; } } }
this function recursively visits the nodes of the viterbi derivation in a depth - first traversal , applying the walker to each of the nodes . it provides a more general framework for implementing operations on a tree .
