// contain n2;
// for every statement in p2 with no other anonymous node than n2 check
// if there is an identical statement in p1, otherwise add {n1, n2} to
// knownNotImpying an return false;
P2_ITER: for (Iterator<Triple> iterP2 = p2.iterator(); iterP2.hasNext();) {
Triple currentP2 = iterP2.next();
if (!containsNoOtherAnon(currentP2, n2)) {
for (Iterator<Triple> iterP1 = p1.iterator(); iterP1.hasNext();) {
Triple currentP1 = iterP1.next();
Triple currentP1Replaced = replaceInStmt(currentP1, n1,
n2);
if (currentP1Replaced.equals(currentP2)) {
iterP2.remove();
continue P2_ITER;
}
}
knownNotImplying.add(currentPair);
return false;
}
}
history1.add(n1);
history2.add(n2);
// for every other statement (n2, p, o2) or (o2, p, n2) in p2 check if
// there is a statement (n1, p, o1) respectively (o1, p, n1) in p1 with
// the same predicate and for which implies(o1, o2,
// history1.clone(),history2.clone(), knownNotImplying,
// conditionalImplications) is true, otherwise add {n1, n2} to
// knownNotImpying an return false;
// first round: just check direction and property-type, add checkPairs
// to
// will fail if for any entry of the set, all pairs in the contained set do not matchs
Set<Set<Node[]>> checkingSets = new HashSet<Set<Node[]>>();
P2_ITER: for (Iterator<Triple> iterP2 = p2.iterator(); iterP2.hasNext();) {
Triple currentP2 = iterP2.next();;
boolean forwardP2 = currentP2.getSubject().equals(n2);
Set<Node[]> pairsToCheck = new HashSet<Node[]>();
for (Iterator<Triple> iterP1 = p1.iterator(); iterP1.hasNext();) {
Triple currentP1 = iterP1.next();
boolean forwardP1 = currentP1.getSubject().equals(n1);
if ((forwardP1 == forwardP2)
&& currentP1.getPredicate().equals(
currentP2.getPredicate())) {
Node[] currentPairToCheck = new Node[2];
if (forwardP1) {
currentPairToCheck[0] = currentP1.getObject();
currentPairToCheck[1] = currentP2.getObject();
} else {
currentPairToCheck[0] = currentP1.getSubject();
currentPairToCheck[1] = currentP2.getSubject();
}
//Fixing: if p1 contains multiple statements with same property and direction this may not be the right match
pairsToCheck.add(currentPairToCheck);
}