@Test public void testGraphContainment() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); LogicalGraph g0 = loader.getLogicalGraphByVariable("g0"); LogicalGraph g2 = loader.getLogicalGraphByVariable("g2"); Collection<EPGMVertex> vertices0 = new HashSet<>(); Collection<EPGMEdge> edges0 = new HashSet<>(); Collection<EPGMVertex> vertices2 = new HashSet<>(); Collection<EPGMEdge> edges2 = new HashSet<>(); Collection<EPGMVertex> resVertices = new HashSet<>(); Collection<EPGMEdge> resEdges = new HashSet<>(); LogicalGraph res = g0.overlap(g2); g0.getVertices().output(new LocalCollectionOutputFormat<>(vertices0)); g0.getEdges().output(new LocalCollectionOutputFormat<>(edges0)); g2.getVertices().output(new LocalCollectionOutputFormat<>(vertices2)); g2.getEdges().output(new LocalCollectionOutputFormat<>(edges2)); res.getVertices().output(new LocalCollectionOutputFormat<>(resVertices)); res.getEdges().output(new LocalCollectionOutputFormat<>(resEdges)); getExecutionEnvironment().execute(); Set<EPGMGraphElement> inVertices = new HashSet<>(); for (EPGMVertex vertex : vertices0) { if (vertices2.contains(vertex)) { inVertices.add(vertex); } } for (EPGMEdge edge : edges0) { if (edges2.contains(edge)) { inVertices.add(edge); } } Set<EPGMGraphElement> outVertices = new HashSet<>(); inVertices.addAll(outVertices); Set<EPGMGraphElement> outEdges = new HashSet<>(); Set<EPGMGraphElement> inEdges = new HashSet<>(resEdges); checkElementMatches(inVertices, outVertices); checkElementMatches(inEdges, outEdges); }
@Override public LG execute(LG firstGraph, LG secondGraph) { DataSet<V> newVertices = firstGraph.getVertices() .join(secondGraph.getVertices()) .where(new Id<>()) .equalTo(new Id<>()) .with(new LeftSide<>()); DataSet<E> newEdges = firstGraph.getEdges() .join(secondGraph.getEdges()) .where(new Id<>()) .equalTo(new Id<>()) .with(new LeftSide<>()); return firstGraph.getFactory().fromDataSets(newVertices, newEdges); }
Overlap implements BinaryBaseGraphToBaseGraphOperator<LG> { @Override public LG execute(LG firstGraph, LG secondGraph) { DataSet<V> newVertices = firstGraph.getVertices() .join(secondGraph.getVertices()) .where(new Id<>()) .equalTo(new Id<>()) .with(new LeftSide<>()); DataSet<E> newEdges = firstGraph.getEdges() .join(secondGraph.getEdges()) .where(new Id<>()) .equalTo(new Id<>()) .with(new LeftSide<>()); return firstGraph.getFactory().fromDataSets(newVertices, newEdges); } }
Overlap implements BinaryBaseGraphToBaseGraphOperator<LG> { @Override public LG execute(LG firstGraph, LG secondGraph) { DataSet<V> newVertices = firstGraph.getVertices() .join(secondGraph.getVertices()) .where(new Id<>()) .equalTo(new Id<>()) .with(new LeftSide<>()); DataSet<E> newEdges = firstGraph.getEdges() .join(secondGraph.getEdges()) .where(new Id<>()) .equalTo(new Id<>()) .with(new LeftSide<>()); return firstGraph.getFactory().fromDataSets(newVertices, newEdges); }  }
Overlap implements BinaryBaseGraphToBaseGraphOperator<LG> { @Override public LG execute(LG firstGraph, LG secondGraph) { DataSet<V> newVertices = firstGraph.getVertices() .join(secondGraph.getVertices()) .where(new Id<>()) .equalTo(new Id<>()) .with(new LeftSide<>()); DataSet<E> newEdges = firstGraph.getEdges() .join(secondGraph.getEdges()) .where(new Id<>()) .equalTo(new Id<>()) .with(new LeftSide<>()); return firstGraph.getFactory().fromDataSets(newVertices, newEdges); }  @Override LG execute(LG firstGraph, LG secondGraph); }
Overlap implements BinaryBaseGraphToBaseGraphOperator<LG> { @Override public LG execute(LG firstGraph, LG secondGraph) { DataSet<V> newVertices = firstGraph.getVertices() .join(secondGraph.getVertices()) .where(new Id<>()) .equalTo(new Id<>()) .with(new LeftSide<>()); DataSet<E> newEdges = firstGraph.getEdges() .join(secondGraph.getEdges()) .where(new Id<>()) .equalTo(new Id<>()) .with(new LeftSide<>()); return firstGraph.getFactory().fromDataSets(newVertices, newEdges); }  @Override LG execute(LG firstGraph, LG secondGraph);  }