コード例 #1
0
 private int getMaxLevelOfParent(EntityNode node) {
   int max = -1;
   for (EntityNode parent : node.getParent()) {
     if (max < parent.getLevel()) {
       max = parent.getLevel();
     }
   }
   return max;
 }
コード例 #2
0
  private void computeNodeLevel(ActionGraph actionGraph) {
    int max = actionGraph.getAllNodes().size();
    int count = 0;
    while (true && count++ < max) {
      boolean noChange = true;
      for (EntityNode node : actionGraph.getAllNodes()) {
        int maxParentLevel = getMaxLevelOfParent(node);
        int toBeNodeLevel = maxParentLevel + 1;
        if (toBeNodeLevel > node.getLevel()) {
          node.setLevel(toBeNodeLevel);
          noChange = false;
        }
      }

      if (noChange) {
        break;
      }
    }
  }
コード例 #3
0
 @Override
 public int compare(EntityNode o1, EntityNode o2) {
   return o1.getLevel() - o2.getLevel();
 }