impl/maven-core/src/main/java/org/apache/maven/project/Graph.java [88:109]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private static List<String> visitCycle(
            Collection<Vertex> children, Map<Vertex, DfsState> stateMap, LinkedList<String> cycle) {
        for (Vertex v : children) {
            DfsState state = stateMap.putIfAbsent(v, DfsState.VISITING);
            if (state == null) {
                cycle.addLast(v.label);
                List<String> ret = visitCycle(v.children, stateMap, cycle);
                if (ret != null) {
                    return ret;
                }
                cycle.removeLast();
                stateMap.put(v, DfsState.VISITED);
            } else if (state == DfsState.VISITING) {
                // we are already visiting this vertex, this mean we have a cycle
                int pos = cycle.lastIndexOf(v.label);
                List<String> ret = cycle.subList(pos, cycle.size());
                ret.add(v.label);
                return ret;
            }
        }
        return null;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



impl/maven-core/src/main/java/org/apache/maven/internal/impl/Graph.java [88:109]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private static List<String> visitCycle(
            Collection<Vertex> children, Map<Vertex, DfsState> stateMap, LinkedList<String> cycle) {
        for (Vertex v : children) {
            DfsState state = stateMap.putIfAbsent(v, DfsState.VISITING);
            if (state == null) {
                cycle.addLast(v.label);
                List<String> ret = visitCycle(v.children, stateMap, cycle);
                if (ret != null) {
                    return ret;
                }
                cycle.removeLast();
                stateMap.put(v, DfsState.VISITED);
            } else if (state == DfsState.VISITING) {
                // we are already visiting this vertex, this mean we have a cycle
                int pos = cycle.lastIndexOf(v.label);
                List<String> ret = cycle.subList(pos, cycle.size());
                ret.add(v.label);
                return ret;
            }
        }
        return null;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



