예제 #1
0
 private void assignLevels(List<Node> topologicalOrder, LevelAssignmentDirection direction) {
   for (Node currentNode : topologicalOrder) {
     int nextLevel = direction.getNextLevel(currentNode);
     List<Node> relatedNodes = direction.getRelatedNodes(currentNode);
     if (!relatedNodes.isEmpty()) {
       for (Node relatedNode : relatedNodes) {
         if (direction.canResetLevel(relatedNode, nextLevel)) {
           relatedNode.setLevel(nextLevel);
         }
       }
     }
   }
 }
예제 #2
0
  public NodeLevelMap apply(ValueStreamMap valueStreamMap) {
    Node rootNode =
        valueStreamMap.getCurrentPipeline() != null
            ? valueStreamMap.getCurrentPipeline()
            : valueStreamMap.getCurrentMaterial();
    rootNode.setLevel(0);

    if (!rootNode.getParents().isEmpty()) {
      assignLevelsToDependencies(rootNode, new Upstream());
    }

    if (!rootNode.getChildren().isEmpty()) {
      assignLevelsToDependencies(rootNode, new Downstream());
    }

    return levelToNodesMap(valueStreamMap);
  }
예제 #3
0
 @Override
 public boolean canResetLevel(Node node, int nextLevel) {
   return nextLevel > node.getLevel();
 }
예제 #4
0
 @Override
 public int getNextLevel(Node node) {
   return node.getLevel() + 1;
 }
예제 #5
0
 @Override
 public List<Node> getRelatedNodes(Node node) {
   return node.getChildren();
 }
예제 #6
0
 @Override
 public List<Node> getRelatedNodes(Node node) {
   return node.getParents();
 }