public static Trellis orderTrellis(Trellis trel,double I[][],Random rand){
  int L=I.length;
  int Y[]=new int[L];
  ArrayList<Integer> list=new ArrayList<Integer>();
  for (  int i : trel.indices) {
    list.add(new Integer(i));
  }
  Y[0]=list.remove(rand.nextInt(L));
  for (int j=1; j < L; j++) {
    double max_w=-1.;
    int j_=-1;
    for (    int j_prop : list) {
      double w=trel.weight(Y,j,j_prop,I);
      if (w >= max_w) {
        max_w=w;
        j_=j_prop;
      }
    }
    list.remove(new Integer(j_));
    Y[j]=j_;
  }
  trel=new Trellis(Y,trel.WIDTH,trel.TYPE);
  return trel;
}

public static Trellis orderTrellis ( Trellis trel , double I [ ] [ ] , Random rand ) { int L = I . length ; int Y [ ] = new int [ L ] ; ArrayList < Integer > list = new ArrayList < Integer > ( ) ; for ( int i : trel . indices ) { list . add ( new Integer ( i ) ) ; } Y [ 0 ] = list . remove ( rand . nextInt ( L ) ) ; for ( int j = 1 ; j < L ; j ++ ) { double max_w = - 1. ; int j_ = - 1 ; for ( int j_prop : list ) { double w = trel . weight ( Y , j , j_prop , I ) ; if ( w >= max_w ) { max_w = w ; j_ = j_prop ; } } list . remove ( new Integer ( j_ ) ) ; Y [ j ] = j_ ; } trel = new Trellis ( Y , trel . WIDTH , trel . TYPE ) ; return trel ; }
ordertrellis - order the trellis according to marginal label dependencies .
