@Override public void propagate(int evtmask) throws ContradictionException { for (int i = 0; i < n; i++) { sccFirst[i].set(-1); sccNext[i].set(-1); mates[i].clear(); G_R.getActiveNodes().desactivate(i); } ArrayList<TIntArrayList> allSCC = StrongConnectivityFinder.findAllSCCOf(G.getEnvelopGraph()); int s = allSCC.size(); n_R.set(s); int elem; TIntArrayList list; for (int i = 0; i < s; i++) { list = allSCC.get(i); G_R.getActiveNodes().activate(i); for (int j = list.size() - 1; j >= 0; j--) { elem = list.get(j); sccOf[elem].set(i); addNode(i, elem); } } INeighbors succs; int x; for (int i = 0; i < n; i++) { x = sccOf[i].get(); succs = G.getEnvelopGraph().getSuccessorsOf(i); for (int j = succs.getFirstElement(); j >= 0; j = succs.getNextElement()) { if (x != sccOf[j].get()) { G_R.addArc(x, sccOf[j].get()); mates[x].add((i + 1) * n + j); } } } int first = -1; int last = -1; for (int i = 0; i < s; i++) { if (G_R.getPredecessorsOf(i).isEmpty()) { first = i; } if (G_R.getSuccessorsOf(i).isEmpty()) { last = i; } } if (first == -1 || last == -1 || first == last) { contradiction(G, ""); } if (visit(first, last) != n_R.get()) { contradiction(G, ""); } int to, arc; for (int i = 0; i < n; i++) { to = G.getKernelGraph().getSuccessorsOf(i).getFirstElement(); x = sccOf[i].get(); if (to != -1 && sccOf[to].get() != x && mates[x].neighborhoodSize() > 1) { arc = (i + 1) * n + to; for (int a = mates[x].getFirstElement(); a >= 0; a = mates[x].getNextElement()) { if (a != arc) { G.removeArc(a / n - 1, a % n, this); } } mates[x].clear(); mates[x].add(arc); } } }