Search in sources :

Example 1 with TransitiveGraphCache

use of org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache in project jena by apache.

the class TestTransitiveGraphCache method testEquivalencesSimple.

/**
     * Test simple equivalences case
     */
public void testEquivalencesSimple() {
    TransitiveGraphCache cache = new TransitiveGraphCache(directP, closedP);
    cache.addRelation(new Triple(a, closedP, b));
    cache.addRelation(new Triple(b, closedP, a));
    TestUtil.assertIteratorValues(this, cache.find(new TriplePattern(null, closedP, null)), new Object[] { new Triple(a, closedP, b), new Triple(b, closedP, a), new Triple(b, closedP, b), new Triple(a, closedP, a) });
    TestUtil.assertIteratorLength(cache.find(new TriplePattern(null, closedP, null)), 4);
}
Also used : Triple(org.apache.jena.graph.Triple) TriplePattern(org.apache.jena.reasoner.TriplePattern) TransitiveGraphCache(org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache)

Example 2 with TransitiveGraphCache

use of org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache in project jena by apache.

the class TestTransitiveGraphCache method testCycle.

/**
     * Test cycle detection.
     */
public void testCycle() {
    TransitiveGraphCache cache = new TransitiveGraphCache(directP, closedP);
    cache.addRelation(new Triple(a, closedP, b));
    cache.addRelation(new Triple(b, closedP, c));
    cache.addRelation(new Triple(a, closedP, c));
    cache.addRelation(new Triple(c, closedP, b));
    TestUtil.assertIteratorValues(this, cache.find(new TriplePattern(a, directP, null)), new Object[] { new Triple(a, closedP, a), new Triple(a, closedP, b), new Triple(a, closedP, c) });
}
Also used : Triple(org.apache.jena.graph.Triple) TriplePattern(org.apache.jena.reasoner.TriplePattern) TransitiveGraphCache(org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache)

Example 3 with TransitiveGraphCache

use of org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache in project jena by apache.

the class TestTransitiveGraphCache method testBug1.

/**
     * Test a a case where an earlier version had a bug due to removing
     * a link which was required rather than redundant.
     */
public void testBug1() {
    TransitiveGraphCache cache = new TransitiveGraphCache(directP, closedP);
    cache.addRelation(new Triple(a, closedP, b));
    cache.addRelation(new Triple(c, closedP, a));
    cache.addRelation(new Triple(c, closedP, b));
    cache.addRelation(new Triple(a, closedP, c));
    TestUtil.assertIteratorValues(this, cache.find(new TriplePattern(a, directP, null)), new Object[] { new Triple(a, closedP, a), new Triple(a, closedP, b), new Triple(a, closedP, c) });
}
Also used : Triple(org.apache.jena.graph.Triple) TriplePattern(org.apache.jena.reasoner.TriplePattern) TransitiveGraphCache(org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache)

Example 4 with TransitiveGraphCache

use of org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache in project jena by apache.

the class TestTransitiveGraphCache method testCycle2.

/**
     * A ring of three cycle
     */
public void testCycle2() {
    TransitiveGraphCache cache = new TransitiveGraphCache(directP, closedP);
    cache.addRelation(new Triple(a, closedP, b));
    cache.addRelation(new Triple(a, closedP, c));
    cache.addRelation(new Triple(f, closedP, b));
    cache.addRelation(new Triple(b, closedP, g));
    cache.addRelation(new Triple(b, closedP, d));
    cache.addRelation(new Triple(d, closedP, c));
    cache.addRelation(new Triple(d, closedP, e));
    cache.addRelation(new Triple(c, closedP, e));
    cache.addRelation(new Triple(c, closedP, b));
    TestUtil.assertIteratorValues(this, cache.find(new TriplePattern(c, directP, null)), new Object[] { new Triple(c, closedP, e), new Triple(c, closedP, g), new Triple(c, closedP, b), new Triple(c, closedP, d), new Triple(c, closedP, c) });
    TestUtil.assertIteratorValues(this, cache.find(new TriplePattern(null, directP, c)), new Object[] { new Triple(a, closedP, c), new Triple(b, closedP, c), new Triple(d, closedP, c), new Triple(f, closedP, c), new Triple(c, closedP, c) });
    TestUtil.assertIteratorValues(this, cache.find(new TriplePattern(f, closedP, null)), new Object[] { new Triple(f, closedP, f), new Triple(f, closedP, b), new Triple(f, closedP, c), new Triple(f, closedP, d), new Triple(f, closedP, g), new Triple(f, closedP, e) });
}
Also used : Triple(org.apache.jena.graph.Triple) TriplePattern(org.apache.jena.reasoner.TriplePattern) TransitiveGraphCache(org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache)

Example 5 with TransitiveGraphCache

use of org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache in project jena by apache.

the class TestTransitiveGraphCache method testDirect.

/**
     * Test direct link case with adverse ordering.
     */
public void testDirect() {
    TransitiveGraphCache cache = new TransitiveGraphCache(directP, closedP);
    cache.addRelation(new Triple(a, closedP, b));
    cache.addRelation(new Triple(c, closedP, d));
    cache.addRelation(new Triple(a, closedP, d));
    cache.addRelation(new Triple(b, closedP, c));
    TestUtil.assertIteratorValues(this, cache.find(new TriplePattern(a, directP, null)), new Object[] { new Triple(a, closedP, a), new Triple(a, closedP, b) });
}
Also used : Triple(org.apache.jena.graph.Triple) TriplePattern(org.apache.jena.reasoner.TriplePattern) TransitiveGraphCache(org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache)

Aggregations

Triple (org.apache.jena.graph.Triple)11 TransitiveGraphCache (org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache)11 TriplePattern (org.apache.jena.reasoner.TriplePattern)9