public static <NodeType extends IGraphNode<NodeType>>
      HashMap<NodeType, ArrayList<NodeType>> getBackEdges(
          final IDirectedGraph<NodeType, ?> graph, final NodeType rootNode)
          throws MalformedGraphException {
    Preconditions.checkNotNull(graph, "Error: Graph argument can not be null");
    Preconditions.checkNotNull(rootNode, "Error: Root Node argument can not be null");

    final HashMap<NodeType, ArrayList<NodeType>> nodeToBackedges =
        new HashMap<NodeType, ArrayList<NodeType>>();
    final Pair<
            com.google.security.zynamics.zylib.types.trees.Tree<NodeType>,
            HashMap<NodeType, ITreeNode<NodeType>>>
        dominatorPair = LengauerTarjan.calculate(graph, rootNode);
    final HashMap<NodeType, ITreeNode<NodeType>> dominatorTreeMapping = dominatorPair.second();
    final HashMap<ITreeNode<NodeType>, Set<ITreeNode<NodeType>>> treeNodeDominateRelation =
        TreeAlgorithms.getDominateRelation(dominatorPair.first().getRootNode());

    for (final NodeType t : graph.getNodes()) {
      final ArrayList<NodeType> currentNodesBackedges = new ArrayList<NodeType>();

      final Set<ITreeNode<NodeType>> currentTreeNodeDominateRelation =
          treeNodeDominateRelation.get(dominatorTreeMapping.get(t));

      if (currentTreeNodeDominateRelation != null) {
        for (final NodeType graphNode : t.getChildren()) {
          if (currentTreeNodeDominateRelation.contains(dominatorTreeMapping.get(graphNode))) {
            currentNodesBackedges.add(graphNode);
          }
        }
      }

      nodeToBackedges.put(t, currentNodesBackedges);
    }

    return nodeToBackedges;
  }
Calculates the back edges of the current graph.

@param graph The input graph.
@param <NodeType> rootNode The root node of the graph.
@return A HashMap which contains the relation of nodes and their respective back edges.
@throws MalformedGraphException Thrown if the graph has more then one entry node.
java/zylib/src/main/java/com/google/security/zynamics/zylib/types/graphs/GraphAlgorithms.java