void (int startIndex, int vertexIndex) { Node vertex = toV(vertexIndex); myVIndex.put(vertex, myIndex); myVLowlink.put(vertex, myIndex); myIndex++; myPath.push(vertex); myPathSet.add(vertex); Set<Node> successors = new HashSet<>(); myGraph.getOut(vertex).forEachRemaining(successors::add); for (Node successor : successors) { int successorIndex = toI(successor); if (successorIndex < startIndex) { continue; } if (!myVIndex.containsKey(successor)) { getSCCs(startIndex, successorIndex); myVLowlink.put(vertex, Math.min(myVLowlink.get(vertex), myVLowlink.get(successor))); } else if (myPathSet.contains(successor)) { myVLowlink.put(vertex, Math.min(myVLowlink.get(vertex), myVIndex.get(successor))); } } if (myVLowlink.get(vertex).equals(myVIndex.get(vertex))) { Set<Node> result = new HashSet<>(); Node temp; do { temp = myPath.pop(); myPathSet.remove(temp); result.add(temp); } while (!vertex.equals(temp)); if (result.size() == 1) { Node Node = result.iterator().next(); if (successors.contains(Node)) { myFoundSCCs.add(result); } } else { myFoundSCCs.add(result); } } }