@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 expected = g0.combine(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)); expected.getVertices().output(new LocalCollectionOutputFormat<>(resVertices)); expected.getEdges().output(new LocalCollectionOutputFormat<>(resEdges)); getExecutionEnvironment().execute(); Set<EPGMGraphElement> inVertices = new HashSet<>(); inVertices.addAll(vertices0); inVertices.addAll(vertices2); Set<EPGMGraphElement> inEdges = new HashSet<>(); inEdges.addAll(edges0); inEdges.addAll(edges2); Set<EPGMGraphElement> outVertices = new HashSet<>(); inVertices.addAll(outVertices); Set<EPGMGraphElement> outEdges = new HashSet<>(); inEdges.addAll(resEdges); checkElementMatches(inVertices, outVertices); checkElementMatches(inEdges, outEdges); }
@Override public LG execute(LG firstGraph, LG secondGraph) { DataSet<V> newVertexSet = firstGraph.getVertices() .union(secondGraph.getVertices()) .distinct(new Id<>()); DataSet<E> newEdgeSet = firstGraph.getEdges() .union(secondGraph.getEdges()) .distinct(new Id<>()); return firstGraph.getFactory().fromDataSets(newVertexSet, newEdgeSet); }
Combination implements BinaryBaseGraphToBaseGraphOperator<LG> { @Override public LG execute(LG firstGraph, LG secondGraph) { DataSet<V> newVertexSet = firstGraph.getVertices() .union(secondGraph.getVertices()) .distinct(new Id<>()); DataSet<E> newEdgeSet = firstGraph.getEdges() .union(secondGraph.getEdges()) .distinct(new Id<>()); return firstGraph.getFactory().fromDataSets(newVertexSet, newEdgeSet); } }
Combination implements BinaryBaseGraphToBaseGraphOperator<LG> { @Override public LG execute(LG firstGraph, LG secondGraph) { DataSet<V> newVertexSet = firstGraph.getVertices() .union(secondGraph.getVertices()) .distinct(new Id<>()); DataSet<E> newEdgeSet = firstGraph.getEdges() .union(secondGraph.getEdges()) .distinct(new Id<>()); return firstGraph.getFactory().fromDataSets(newVertexSet, newEdgeSet); }  }
Combination implements BinaryBaseGraphToBaseGraphOperator<LG> { @Override public LG execute(LG firstGraph, LG secondGraph) { DataSet<V> newVertexSet = firstGraph.getVertices() .union(secondGraph.getVertices()) .distinct(new Id<>()); DataSet<E> newEdgeSet = firstGraph.getEdges() .union(secondGraph.getEdges()) .distinct(new Id<>()); return firstGraph.getFactory().fromDataSets(newVertexSet, newEdgeSet); }  @Override LG execute(LG firstGraph, LG secondGraph); }
Combination implements BinaryBaseGraphToBaseGraphOperator<LG> { @Override public LG execute(LG firstGraph, LG secondGraph) { DataSet<V> newVertexSet = firstGraph.getVertices() .union(secondGraph.getVertices()) .distinct(new Id<>()); DataSet<E> newEdgeSet = firstGraph.getEdges() .union(secondGraph.getEdges()) .distinct(new Id<>()); return firstGraph.getFactory().fromDataSets(newVertexSet, newEdgeSet); }  @Override LG execute(LG firstGraph, LG secondGraph);  }