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; } } }
private List<EntityNode> getEntityNodeInOrderOfLevelFrom(ActionGraph actionGraph) { EntityNode[] arrayData = actionGraph.getAllNodes().toArray(new EntityNode[0]); Arrays.sort(arrayData, ENTITY_LEVEL_COMPARATOR); return Arrays.asList(arrayData); }