@Override protected Intersection createNewGraph() { Graph g1 = memGraph(); Graph g2 = memGraph(); Intersection retval = new Intersection(g1, g2); dependencyGraph.put(retval, new Graph[] { g1, g2 }); return retval; }
@Override protected ExtendedIterator<Triple> _graphBaseFind(Triple s) { return L.isEmpty() || R.isEmpty() ? NullIterator.instance() : super._graphBaseFind(s); } }
@Override public void performDelete( Triple t ) { if (this.contains( t )) L.delete( t ); }
@ContractTest public void testIntersection() { Graph g1 = graphWith( "x R y; p R q"); Graph g2 = graphWith( "r Foo s; x R y"); Intersection i = new Intersection(g1, g2); assertContains("Intersection", "x R y", i); assertOmits("Intersection", i, "p R q"); assertOmits("Intersection", i, "r Foo s"); if (i.size() != 1) fail("oops: size of intersection is not 1"); i.add(triple("cats eat cheese")); assertContains("Intersection.L", "cats eat cheese", g1); assertContains("Intersection.R", "cats eat cheese", g2); }
public void testDelete() { Graph l = graphWith( "r A s; x R y" ); Graph r = graphWith( "x R y; p S q" ); Intersection isec = new Intersection( l, r ); assertIsomorphic( graphWith( "x R y" ), isec ); // removing non-contained triples is a no-op isec.delete( triple( "r A s" ) ); assertIsomorphic( graphWith( "r A s; x R y" ), l); isec.delete( triple( "p S q" ) ); assertIsomorphic( graphWith( "x R y; p S q" ), r); // removing a contained triple removes it from the left operand isec.delete( triple( "x R y" ) ); assertIsomorphic( graphWith( "" ), isec ); assertIsomorphic( graphWith( "r A s" ), l ); assertIsomorphic( graphWith( "x R y; p S q" ), r ); } }
public void testAdd() { Graph l = graphWith( "x R y" ); Graph r = graphWith( "p S q" ); Intersection isec = new Intersection( l, r ); assertIsomorphic( graphWith( "" ), isec ); isec.add( triple( "r A s" ) ); assertIsomorphic( graphWith( "r A s" ), isec ); assertIsomorphic( graphWith( "x R y; r A s" ), l ); assertIsomorphic( graphWith( "p S q; r A s" ), r ); isec.add( triple ( "x R y" ) ); assertIsomorphic( graphWith( "r A s; x R y" ), isec ); assertIsomorphic( graphWith( "x R y; r A s" ), l ); assertIsomorphic( graphWith( "p S q; r A s; x R y" ), r ); isec.add( triple ( "p S q" ) ); assertIsomorphic( graphWith( "p S q; r A s; x R y" ), isec ); assertIsomorphic( graphWith( "p S q; r A s; x R y" ), l ); assertIsomorphic( graphWith( "p S q; r A s; x R y" ), r ); }
@Override protected ExtendedIterator<Triple> _graphBaseFind( Triple s ) { return L.find( s ) .filterKeep( ifIn( R ) ); } }
@ContractTest public void testIntersection() { Graph g1 = graphWith( "x R y; p R q"); Graph g2 = graphWith( "r Foo s; x R y"); Intersection i = new Intersection(g1, g2); assertContains("Intersection", "x R y", i); assertOmits("Intersection", i, "p R q"); assertOmits("Intersection", i, "r Foo s"); if (i.size() != 1) fail("oops: size of intersection is not 1"); i.add(triple("cats eat cheese")); assertContains("Intersection.L", "cats eat cheese", g1); assertContains("Intersection.R", "cats eat cheese", g2); }
public void testDelete() { Graph l = graphWith( "r A s; x R y" ); Graph r = graphWith( "x R y; p S q" ); Intersection isec = new Intersection( l, r ); assertIsomorphic( graphWith( "x R y" ), isec ); // removing non-contained triples is a no-op isec.delete( triple( "r A s" ) ); assertIsomorphic( graphWith( "r A s; x R y" ), l); isec.delete( triple( "p S q" ) ); assertIsomorphic( graphWith( "x R y; p S q" ), r); // removing a contained triple removes it from the left operand isec.delete( triple( "x R y" ) ); assertIsomorphic( graphWith( "" ), isec ); assertIsomorphic( graphWith( "r A s" ), l ); assertIsomorphic( graphWith( "x R y; p S q" ), r ); } }
public void testAdd() { Graph l = graphWith( "x R y" ); Graph r = graphWith( "p S q" ); Intersection isec = new Intersection( l, r ); assertIsomorphic( graphWith( "" ), isec ); isec.add( triple( "r A s" ) ); assertIsomorphic( graphWith( "r A s" ), isec ); assertIsomorphic( graphWith( "x R y; r A s" ), l ); assertIsomorphic( graphWith( "p S q; r A s" ), r ); isec.add( triple ( "x R y" ) ); assertIsomorphic( graphWith( "r A s; x R y" ), isec ); assertIsomorphic( graphWith( "x R y; r A s" ), l ); assertIsomorphic( graphWith( "p S q; r A s; x R y" ), r ); isec.add( triple ( "p S q" ) ); assertIsomorphic( graphWith( "p S q; r A s; x R y" ), isec ); assertIsomorphic( graphWith( "p S q; r A s; x R y" ), l ); assertIsomorphic( graphWith( "p S q; r A s; x R y" ), r ); }
@Override protected ExtendedIterator<Triple> _graphBaseFind( Triple s ) { return L.find( s ) .filterKeep( ifIn( R ) ); } }
@Override protected Intersection createNewGraph() { Graph g1 = memGraph(); Graph g2 = memGraph(); Intersection retval = new Intersection(g1, g2); dependencyGraph.put(retval, new Graph[] { g1, g2 }); return retval; }
@Override public void performDelete( Triple t ) { if (this.contains( t )) L.delete( t ); }
@Override public Graph getGraph() { Graph gBase = graphWith( "" ), g1 = graphWith( "" ); return new Intersection( gBase, g1 ); }
@Override Graph getGraph() { return new Intersection(Factory.createGraphMem(), Factory.createGraphMem()); }};
@Override public Graph getGraph() { Graph gBase = graphWith( "" ), g1 = graphWith( "" ); return new Intersection( gBase, g1 ); }
@Override Graph getGraph() { return new Intersection(Factory.createGraphMem(), Factory.createGraphMem()); }};
public Intersection intersectionOf(String s1, String s2) { return new Intersection( graphWith( s1 ), graphWith( s2 ) ); }
public Intersection intersectionOf(String s1, String s2) { return new Intersection( graphWith( s1 ), graphWith( s2 ) ); }
@ContractTest public void testDeleteDoesNotUpdateR() { Graph L = graphWith("a pings b; b pings c; c pings a"); Graph R = graphWith("c pings a; b pings c; x captures y"); Graph join = new Intersection(L, R); GraphUtil.deleteFrom(L, R); assertIsomorphic("R should not change", graphWith("c pings a; b pings c; x captures y"), R); assertIsomorphic(graphWith("a pings b"), L); } }