private static SingleDiffEdge buildDiffEdge(
      final SingleGraph diffGraph, final SuperViewEdge<? extends SuperViewNode> rawSuperJump)
      throws GraphLayoutException {
    SingleDiffEdge diffEdge = null;
    Edge yEdge = null;

    @SuppressWarnings("unchecked")
    final RawCombinedJump<RawCombinedBasicBlock> rawCombinedJump =
        (RawCombinedJump<RawCombinedBasicBlock>) rawSuperJump.getCombinedEdge();

    final RawBasicBlock rawSourceNode = rawCombinedJump.getSource().getRawNode(diffGraph.getSide());
    final RawBasicBlock rawTargetNode = rawCombinedJump.getTarget().getRawNode(diffGraph.getSide());

    final RawJump rawJump =
        diffGraph.getSide() == ESide.PRIMARY
            ? rawCombinedJump.getPrimaryEdge()
            : rawCombinedJump.getSecondaryEdge();

    if (rawJump == null) {
      return null;
    }

    SingleEdgeRealizer edgeRealizer = null;

    if (rawSourceNode != null && rawTargetNode != null && rawJump != null) {
      final ZyLabelContent edgeContent = new ZyLabelContent(null);
      edgeRealizer = new SingleEdgeRealizer(edgeContent, null, diffGraph.getSettings());

      final SingleDiffNode sourceNode = diffGraph.getNode(rawSourceNode);
      final SingleDiffNode targetNode = diffGraph.getNode(rawTargetNode);

      final boolean srcVisible = sourceNode.getRawNode().isVisible();
      final boolean tarVisible = targetNode.getRawNode().isVisible();
      sourceNode.getRawNode().setVisible(true);
      targetNode.getRawNode().setVisible(true);

      yEdge = diffGraph.getGraph().createEdge(sourceNode.getNode(), targetNode.getNode());

      diffEdge =
          new SingleDiffEdge(
              sourceNode, targetNode, yEdge, edgeRealizer, rawJump, diffGraph.getSide());
      SingleDiffNode.link(sourceNode, targetNode);
      edgeRealizer.setUserData(new ZyEdgeData<>(diffEdge));

      sourceNode.getRawNode().setVisible(srcVisible);
      targetNode.getRawNode().setVisible(tarVisible);

      diffGraph.addEdgeToMappings(diffEdge);

      if (!srcVisible || !tarVisible) {
        final BinDiffGraph<?, ?> graph = diffGraph;
        @SuppressWarnings("unchecked")
        final BinDiffGraph<ZyGraphNode<?>, ?> castedGraph = (BinDiffGraph<ZyGraphNode<?>, ?>) graph;

        final boolean autoLayout = LayoutCommandHelper.deactivateAutoLayout(castedGraph);
        try {
          ProximityBrowserUnhideNode.executeStatic(
              castedGraph, srcVisible ? (ZyGraphNode<?>) sourceNode : (ZyGraphNode<?>) targetNode);
        } finally {
          LayoutCommandHelper.activateAutoLayout(castedGraph, autoLayout);
        }
      }
    }

    return diffEdge;
  }
Utility class to remove basic block matches from BinDiff graphs.
java/ui/src/main/java/com/google/security/zynamics/bindiff/graph/helpers/BasicBlockMatchRemover.java