public static LinkVar [ ] getVarsByDist ( int head , boolean isRight , LinkVar [ ] rootVars , LinkVar [ ] [ ] childVars ) { int dir = isRight ? 1 : - 1 ; int maxDist = isRight ? rootVars . length - head - 1 : head - 1 ; LinkVar [ ] varsByDist = new LinkVar [ maxDist ] ; for ( int cDist = 1 ; cDist <= maxDist ; cDist ++ ) { int c = head + dir * cDist ; if ( head == - 1 ) { varsByDist [ cDist - 1 ] = rootVars [ c ] ; } else { varsByDist [ cDist - 1 ] = childVars [ head ] [ c ] ; } } return varsByDist ; }
Gets the variables for this factor ordered from the head outward .