/**
   * Move the source graph into the destination graph using a specified offset.
   *
   * @param destGraph the destination graph.
   * @param sourceGraph the source graph.
   * @param offsetx x coordinate offset.
   * @param offsety y coordinate offset.
   */
  private void moveGraph(
      final FGraph destGraph,
      final FGraph sourceGraph,
      final double offsetx,
      final double offsety) {

    KVector graphOffset = new KVector(offsetx, offsety);
    graphOffset.sub(sourceGraph.getProperty(Properties.BB_UPLEFT));

    for (FNode node : sourceGraph.getNodes()) {
      node.getPosition().add(graphOffset);
      destGraph.getNodes().add(node);
    }

    for (FEdge edge : sourceGraph.getEdges()) {
      for (FBendpoint bendpoint : edge.getBendpoints()) {
        bendpoint.getPosition().add(graphOffset);
      }
      destGraph.getEdges().add(edge);
    }

    for (FLabel label : sourceGraph.getLabels()) {
      label.getPosition().add(graphOffset);
      destGraph.getLabels().add(label);
    }
  }
  /**
   * Perform a DFS starting on the given node and collect all nodes that are found in the
   * corresponding connected component.
   *
   * @param node a node.
   * @param graph a graph representing a connected component, or {@code null}.
   * @param visited boolean indicating for each node whether it was already visited ({@code true})
   *     or not.
   * @param incidence list of incident edges for each node.
   * @return the connected component, or {@code null} if the node was already visited.
   */
  private FGraph dfs(
      final FNode node,
      final FGraph graph,
      final boolean[] visited,
      final List<FEdge>[] incidence) {

    if (!visited[node.id]) {
      visited[node.id] = true;
      FGraph component = graph;
      if (component == null) {
        component = new FGraph();
      }
      component.getNodes().add(node);
      for (FEdge edge : incidence[node.id]) {
        if (edge.getSource() != node) {
          dfs(edge.getSource(), component, visited, incidence);
        }
        if (edge.getTarget() != node) {
          dfs(edge.getTarget(), component, visited, incidence);
        }
        component.getEdges().add(edge);
        component.getLabels().addAll(edge.getLabels());
      }
      return component;
    }
    return null;
  }