Graph data = Factory.createGraphMem();
data.add(new Triple(c, q, d));
String rules =
"[r1: (c r ?x) <- (?x p f(?x b))]" +
"[r2: (?y p f(a ?y)) <- (c q ?y)]";
InfGraph infgraph = createInfGraph(rules, data);
TestUtil.assertIteratorValues(this,
infgraph.find(c, r, null), new Object[] { } );
data.add(new Triple(c, q, a));
rules =
"[r1: (c r ?x) <- (?x p f(?x a))]" +
"[r2: (?y p f(a ?y)) <- (c q ?y)]";
infgraph = createInfGraph(rules, data);
TestUtil.assertIteratorValues(this,
infgraph.find(c, r, null),
new Object[] {
new Triple(c, r, a)
} );
data = Factory.createGraphMem();
data.add(new Triple(a, q, a));
data.add(new Triple(a, q, b));
data.add(new Triple(a, q, c));
data.add(new Triple(b, q, d));
data.add(new Triple(b, q, b));
rules =
"[r1: (c r ?x) <- (?x p ?x)]" +
"[r2: (?x p ?y) <- (a q ?x), (b q ?y)]";
infgraph = createInfGraph(rules, data);
TestUtil.assertIteratorValues(this,
infgraph.find(c, r, null),
new Object[] {
new Triple(c, r, b)
} );
rules =
"[r1: (c r ?x) <- (?x p ?x)]" +
"[r2: (a p ?x) <- (a q ?x)]" ;
infgraph = createInfGraph(rules, data);
TestUtil.assertIteratorValues(this,
infgraph.find(c, r, null),
new Object[] {
new Triple(c, r, a)
} );
}