|
|
@ -31,6 +31,7 @@ import java.util.ArrayList; |
|
|
import java.util.BitSet; |
|
|
import java.util.BitSet; |
|
|
import java.util.LinkedList; |
|
|
import java.util.LinkedList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.function.IntPredicate; |
|
|
|
|
|
|
|
|
import prism.PrismComponent; |
|
|
import prism.PrismComponent; |
|
|
import prism.PrismException; |
|
|
import prism.PrismException; |
|
|
@ -55,6 +56,7 @@ public class SCCComputerTarjan extends SCCComputer |
|
|
private BitSet onStack; |
|
|
private BitSet onStack; |
|
|
/** Should we filter trivial SCCs? */ |
|
|
/** Should we filter trivial SCCs? */ |
|
|
private boolean filterTrivialSCCs; |
|
|
private boolean filterTrivialSCCs; |
|
|
|
|
|
private IntPredicate restrict; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Build (B)SCC computer for a given model. |
|
|
* Build (B)SCC computer for a given model. |
|
|
@ -74,10 +76,11 @@ public class SCCComputerTarjan extends SCCComputer |
|
|
// Methods for SCCComputer interface |
|
|
// Methods for SCCComputer interface |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void computeSCCs(boolean filterTrivialSCCs) throws PrismException |
|
|
|
|
|
|
|
|
public void computeSCCs(boolean filterTrivialSCCs, IntPredicate restrict) throws PrismException |
|
|
{ |
|
|
{ |
|
|
this.filterTrivialSCCs = filterTrivialSCCs; |
|
|
this.filterTrivialSCCs = filterTrivialSCCs; |
|
|
consumer.notifyStart(model); |
|
|
consumer.notifyStart(model); |
|
|
|
|
|
this.restrict = restrict; |
|
|
tarjan(); |
|
|
tarjan(); |
|
|
consumer.notifyDone(); |
|
|
consumer.notifyDone(); |
|
|
} |
|
|
} |
|
|
@ -91,6 +94,8 @@ public class SCCComputerTarjan extends SCCComputer |
|
|
public void tarjan() throws PrismException |
|
|
public void tarjan() throws PrismException |
|
|
{ |
|
|
{ |
|
|
for (int i = 0; i < numNodes; i++) { |
|
|
for (int i = 0; i < numNodes; i++) { |
|
|
|
|
|
if (restrict != null && !restrict.test(i)) |
|
|
|
|
|
continue; // skip state if not one of the relevant states |
|
|
if (nodeList.get(i).lowlink == -1) |
|
|
if (nodeList.get(i).lowlink == -1) |
|
|
tarjan(i); |
|
|
tarjan(i); |
|
|
} |
|
|
} |
|
|
@ -116,6 +121,10 @@ public class SCCComputerTarjan extends SCCComputer |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (restrict != null && !restrict.test(e)) { |
|
|
|
|
|
continue; // ignore edge to state that is not relevant |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Node n = nodeList.get(e); |
|
|
Node n = nodeList.get(e); |
|
|
if (n.index == -1) { |
|
|
if (n.index == -1) { |
|
|
tarjan(e); |
|
|
tarjan(e); |
|
|
|