示例#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();
 }