@Test public void testEdgeInducedSubgraph() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); loader.appendToDatabaseFromString("expected:_DB[" + "(databases)<-[ghtd]-(gdbs)-[ghtg1]->(graphs)" + "(graphs)<-[ghtg2]-(gps)-[ghth]->(hadoop)" + "]"); LogicalGraph input = loader.getLogicalGraph(); LogicalGraph expected = loader.getLogicalGraphByVariable("expected"); LogicalGraph output = input.edgeInducedSubgraph( e -> e.getLabel().equals("hasTag")); collectAndAssertTrue(output.equalsByData(expected)); }
private LG edgeInducedSubgraph(LG superGraph) { DataSet<E> filteredEdges = superGraph.getEdges().filter(edgeFilterFunction); DataSet<V> inducedVertices = filteredEdges .join(superGraph.getVertices()) .where(new SourceId<>()).equalTo(new Id<>()) .with(new RightSide<>()) .union(filteredEdges .join(superGraph.getVertices()) .where(new TargetId<>()).equalTo(new Id<>()) .with(new RightSide<>())) .distinct(new Id<>()); return superGraph.getFactory() .fromDataSets(superGraph.getGraphHead(), inducedVertices, filteredEdges); }
Subgraph implements UnaryBaseGraphToBaseGraphOperator<LG> { private LG edgeInducedSubgraph(LG superGraph) { DataSet<E> filteredEdges = superGraph.getEdges().filter(edgeFilterFunction); DataSet<V> inducedVertices = filteredEdges .join(superGraph.getVertices()) .where(new SourceId<>()).equalTo(new Id<>()) .with(new RightSide<>()) .union(filteredEdges .join(superGraph.getVertices()) .where(new TargetId<>()).equalTo(new Id<>()) .with(new RightSide<>())) .distinct(new Id<>()); return superGraph.getFactory() .fromDataSets(superGraph.getGraphHead(), inducedVertices, filteredEdges); } }
Subgraph implements UnaryBaseGraphToBaseGraphOperator<LG> { private LG edgeInducedSubgraph(LG superGraph) { DataSet<E> filteredEdges = superGraph.getEdges().filter(edgeFilterFunction); DataSet<V> inducedVertices = filteredEdges .join(superGraph.getVertices()) .where(new SourceId<>()).equalTo(new Id<>()) .with(new RightSide<>()) .union(filteredEdges .join(superGraph.getVertices()) .where(new TargetId<>()).equalTo(new Id<>()) .with(new RightSide<>())) .distinct(new Id<>()); return superGraph.getFactory() .fromDataSets(superGraph.getGraphHead(), inducedVertices, filteredEdges); } Subgraph(FilterFunction<V> vertexFilterFunction,
    FilterFunction<E> edgeFilterFunction, Strategy strategy); }
Subgraph implements UnaryBaseGraphToBaseGraphOperator<LG> { private LG edgeInducedSubgraph(LG superGraph) { DataSet<E> filteredEdges = superGraph.getEdges().filter(edgeFilterFunction); DataSet<V> inducedVertices = filteredEdges .join(superGraph.getVertices()) .where(new SourceId<>()).equalTo(new Id<>()) .with(new RightSide<>()) .union(filteredEdges .join(superGraph.getVertices()) .where(new TargetId<>()).equalTo(new Id<>()) .with(new RightSide<>())) .distinct(new Id<>()); return superGraph.getFactory() .fromDataSets(superGraph.getGraphHead(), inducedVertices, filteredEdges); } Subgraph(FilterFunction<V> vertexFilterFunction,
    FilterFunction<E> edgeFilterFunction, Strategy strategy); @Override LG execute(LG superGraph); }
Subgraph implements UnaryBaseGraphToBaseGraphOperator<LG> { private LG edgeInducedSubgraph(LG superGraph) { DataSet<E> filteredEdges = superGraph.getEdges().filter(edgeFilterFunction); DataSet<V> inducedVertices = filteredEdges .join(superGraph.getVertices()) .where(new SourceId<>()).equalTo(new Id<>()) .with(new RightSide<>()) .union(filteredEdges .join(superGraph.getVertices()) .where(new TargetId<>()).equalTo(new Id<>()) .with(new RightSide<>())) .distinct(new Id<>()); return superGraph.getFactory() .fromDataSets(superGraph.getGraphHead(), inducedVertices, filteredEdges); } Subgraph(FilterFunction<V> vertexFilterFunction,
    FilterFunction<E> edgeFilterFunction, Strategy strategy); @Override LG execute(LG superGraph);  }