protected final void findIncompatibleTestHelper(LearnerGraph gr,List<StringPair> incompatibles_list)
{
HashSet<StatePair> incompatibles = new HashSet<StatePair>();
for(StringPair p:incompatibles_list)
{
incompatibles.add(new StatePair(gr.findVertex(p.firstElem),gr.findVertex(p.secondElem)));
incompatibles.add(new StatePair(gr.findVertex(p.secondElem),gr.findVertex(p.firstElem)));
}
Set<StatePair> incompatiblePairs = new HashSet<StatePair>();
for(StatePair s:buildSetOfIncompatiblePairsSlowly(gr,ThreadNumber))
{
incompatiblePairs.add(s);incompatiblePairs.add(new StatePair(s.secondElem,s.firstElem));
}
// incompatiblePairs these are the pairs which cannot be merged which may be a larger set than
// the set of clearly incompatible pairs. The difference is that when pairs are merged, more traces
// are created, hence it is possible that some of those new traces will be in conflict.
// Example: states A3 and A2 in findIncompatibleStates6()
HashSet<StatePair> pairs_extra = new HashSet<StatePair>();pairs_extra.addAll(incompatibles);pairs_extra.removeAll(incompatiblePairs);
Assert.assertTrue("compatible pairs included :"+pairs_extra,pairs_extra.isEmpty());
final int size=gr.learnerCache.getAcceptStateNumber()*(gr.learnerCache.getAcceptStateNumber()+1)/2;
final int highNumber = 10000;
int pairs[]=new int[size];for(int i=0;i<pairs.length;++i) pairs[i]=highNumber;
reverseMap = new HashMap<Integer,StatePair>();
for(CmpVertex A:gr.transitionMatrix.keySet())
if (A.isAccept())
for(CmpVertex B:gr.transitionMatrix.keySet())
if (B.isAccept())
reverseMap.put(gr.wmethod.vertexToIntNR(A, B), new StatePair(A,B));
Assert.assertEquals(size,reverseMap.size());
gr.linear.buildMatrix(ThreadNumber);
gr.linear.findIncompatiblePairs(pairs,ThreadNumber);
int cnt=0;
for(int i=0;i<pairs.length;++i)
{
StatePair pair = reverseMap.get(i);
if (incompatibles.contains(pair))
Assert.assertEquals("pair ("+pair.firstElem+","+pair.secondElem+") should be marked as incompatible",PAIR_INCOMPATIBLE,pairs[i]);// this pair is not compatible
else
Assert.assertEquals("invalid counter for pair ("+pair.firstElem+","+pair.secondElem+")",
cnt++,pairs[i]);// pairs should have monotonically increasing numbers