private void assignChildren(GraphNode root,int level){
  if (allreadyDone.contains(root)) {
    return;
  }
  allreadyDone.add(root);
  int nextLevel=level + 1;
  int childLeft=getCurrOffset(nextLevel);
  for (  GraphNode node : orderChildren(root)) {
    assignChildren(node,nextLevel);
  }
  int childRight=getCurrOffset(nextLevel);
  if (childLeft != childRight) {
    assignNode(root,level,(childLeft + childRight) / 2);
  }
 else {
    assignNode(root,level,getCurrOffset(level));
    incrCurrOffset(level);
  }
}

private void assignChildren ( GraphNode root , int level ) { if ( allreadyDone . contains ( root ) ) { return ; } allreadyDone . add ( root ) ; int nextLevel = level + 1 ; int childLeft = getCurrOffset ( nextLevel ) ; for ( GraphNode node : orderChildren ( root ) ) { assignChildren ( node , nextLevel ) ; } int childRight = getCurrOffset ( nextLevel ) ; if ( childLeft != childRight ) { assignNode ( root , level , ( childLeft + childRight ) / 2 ) ; } else { assignNode ( root , level , getCurrOffset ( level ) ) ; incrCurrOffset ( level ) ; } }
recursively assign the position for the given node and all of it ' s descendants . through the use of an alreadydone lookup set , loops and joins in the tree data are prevented .
