private boolean mark(T vertex) { /* * return statements commented out for fail slow behavior detect all nodes in cycles instead of just the first one */ List<T> localCycles = new ArrayList<T>(); marks.put(vertex, marked); for (T u : graph.edgesFrom(vertex)) { if (marks.containsKey(u) && marks.get(u).equals(marked)) { localCycles.add(vertex); // return true; } else if (!marks.containsKey(u)) { if (mark(u)) { localCycles.add(vertex); // return true; } } } marks.put(vertex, complete); // return false; verticesInCycles.addAll(localCycles); return !localCycles.isEmpty(); }
private void verifyPackageStructure() { DirectedGraph<String> graph = new DirectedGraph<String>(); String packageName = child.getAttribute("name"); declaredPackages.put(packageName, child); graph.addNode(packageName); graph.addNode(parent); graph.addEdge(packageName, parent);