コード例 #1
0
  /** {@inheritDoc} */
  @Override
  public CGraph transform(final LGraph inputGraph) {
    layeredGraph = inputGraph;

    // checking if the graph has edges and possibly prohibiting vertical compaction
    hasEdges =
        layeredGraph
            .getLayers()
            .stream()
            .flatMap(l -> l.getNodes().stream())
            .anyMatch(n -> !Iterables.isEmpty(n.getConnectedEdges()));
    EnumSet<Direction> supportedDirections =
        EnumSet.of(Direction.UNDEFINED, Direction.LEFT, Direction.RIGHT);
    if (!hasEdges) {
      supportedDirections.add(Direction.UP);
      supportedDirections.add(Direction.DOWN);
    }

    // initializing fields
    cGraph = new CGraph(supportedDirections);

    // importing LGraphElements into CNodes
    readNodes();

    return cGraph;
  }