/** * Creates a new logical graph by union the vertex and edge sets of all graph * contained in the given collection. * * @param collection input collection * @return combined graph */ @Override public LogicalGraph execute(GraphCollection collection) { return collection.getConfig().getLogicalGraphFactory().fromDataSets( collection.getVertices(), collection.getEdges()); } }
/** * Creates a new logical graph by union the vertex and edge sets of all graph * contained in the given collection. * * @param collection input collection * @return combined graph */ @Override public LogicalGraph execute(GraphCollection collection) { return collection.getConfig().getLogicalGraphFactory().fromDataSets( collection.getVertices(), collection.getEdges()); }
@Override public GraphCollection execute(GraphCollection collection) { return collection.getConfig().getGraphCollectionFactory().fromDataSets( collection.getGraphHeads().distinct(new Id<>()), collection.getVertices(), collection.getEdges()); } }
/** * Creates the meta data for the given graph collection. * * @param graphs graph collection * @return meta data information */ default DataSet<Tuple3<String, String, String>> tuplesFromCollection(GraphCollection graphs) { return tuplesFromElements(graphs.getVertices()) .union(tuplesFromElements(graphs.getEdges())) .union(tuplesFromElements(graphs.getGraphHeads())); }
@Override public GraphCollection execute(GraphCollection collection) { return collection.getConfig().getGraphCollectionFactory().fromDataSets( collection.getGraphHeads().distinct(new Id<>()), collection.getVertices(), collection.getEdges()); }
/** * Creates the meta data for the given graph collection. * * @param graphs graph collection * @return meta data information */ default DataSet<Tuple3<String, String, String>> tuplesFromCollection(GraphCollection graphs) { return tuplesFromElements(graphs.getVertices()) .union(tuplesFromElements(graphs.getEdges())) .union(tuplesFromElements(graphs.getGraphHeads())); }
@Override public GraphCollection executeForGVELayout(GraphCollection collection) { // the resulting logical graph holds multiple graph heads LogicalGraph modifiedGraph = executeInternal( collection.getGraphHeads(), collection.getVertices(), collection.getEdges(), collection.getConfig().getLogicalGraphFactory()); return collection.getFactory().fromDataSets( modifiedGraph.getGraphHead(), modifiedGraph.getVertices(), modifiedGraph.getEdges()); }
@Override public GraphCollection executeForGVELayout(GraphCollection collection) { // the resulting logical graph holds multiple graph heads LogicalGraph modifiedGraph = executeInternal( collection.getGraphHeads(), collection.getVertices(), collection.getEdges(), collection.getConfig().getLogicalGraphFactory()); return collection.getFactory().fromDataSets( modifiedGraph.getGraphHead(), modifiedGraph.getVertices(), modifiedGraph.getEdges()); }
@Override public void write(GraphCollection graphCollection, boolean overWrite) throws IOException { FileSystem.WriteMode writeMode = overWrite ? FileSystem.WriteMode.OVERWRITE : FileSystem.WriteMode.NO_OVERWRITE; graphCollection.getGraphHeads().writeAsFormattedText(getGraphHeadPath(), writeMode, new GraphHeadToJSON<>()); graphCollection.getVertices().writeAsFormattedText(getVertexPath(), writeMode, new VertexToJSON<>()); graphCollection.getEdges().writeAsFormattedText(getEdgePath(), writeMode, new EdgeToJSON<>()); } }
@Override public GraphCollection executeForGVELayout(GraphCollection collection) { DataSet<GraphHead> graphHeads = collection.getGraphHeads(); DataSet<GradoopId> graphIds = graphHeads.map(new Id<>()); DataSet<Tuple2<GradoopId, Map<String, PropertyValue>>> aggregate = aggregateVertices(collection.getVertices(), graphIds) .union(aggregateEdges(collection.getEdges(), graphIds)) .groupBy(0) .reduceGroup(new CombinePartitionApplyAggregates(aggregateFunctions)); graphHeads = graphHeads .coGroup(aggregate) .where(new Id<>()).equalTo(0) .with(new SetAggregateProperties(aggregateFunctions)); return collection.getConfig().getGraphCollectionFactory() .fromDataSets(graphHeads, collection.getVertices(), collection.getEdges()); }
@Override public void write(GraphCollection graphCollection, boolean overWrite) throws IOException { FileSystem.WriteMode writeMode = overWrite ? FileSystem.WriteMode.OVERWRITE : FileSystem.WriteMode.NO_OVERWRITE; graphCollection.getGraphHeads().writeAsFormattedText(getGraphHeadPath(), writeMode, new GraphHeadToJSON<>()); graphCollection.getVertices().writeAsFormattedText(getVertexPath(), writeMode, new VertexToJSON<>()); graphCollection.getEdges().writeAsFormattedText(getEdgePath(), writeMode, new EdgeToJSON<>()); } }
@Override public GraphCollection execute(LogicalGraph graph) { LogicalGraph graphWithWccIds = graph.callForGraph(new AnnotateWeaklyConnectedComponents( propertyKey, maxIterations)); GraphCollection split = graphWithWccIds.splitBy(propertyKey); return graph.getConfig().getGraphCollectionFactory().fromDataSets( split.getGraphHeads(), split.getVertices().map(new PropertyRemover<>(propertyKey)), split.getEdges().map(new PropertyRemover<>(propertyKey))); } }
@Override public GraphCollection execute(LogicalGraph graph) { LogicalGraph graphWithWccIds = graph.callForGraph(new AnnotateWeaklyConnectedComponents( propertyKey, maxIterations)); GraphCollection split = graphWithWccIds.splitBy(propertyKey); return graph.getConfig().getGraphCollectionFactory().fromDataSets( split.getGraphHeads(), split.getVertices().map(new PropertyRemover<>(propertyKey)), split.getEdges().map(new PropertyRemover<>(propertyKey))); }
@Override public LogicalGraph getGraph(final GradoopId graphID) { // filter vertices and edges based on given graph id DataSet<GraphHead> graphHead = getGraphHeads() .filter(new BySameId<>(graphID)); DataSet<Vertex> vertices = getVertices() .filter(new InGraph<>(graphID)); DataSet<Edge> edges = getEdges() .filter(new InGraph<>(graphID)); return new LogicalGraph( config.getLogicalGraphFactory().fromDataSets(graphHead, vertices, edges), getConfig()); }
@Override public void write(GraphCollection graphCollection, boolean overWrite) throws IOException { if (overWrite) { getStore().truncateTables(); } graphCollection.getGraphHeads() .output(new ElementOutputFormat<>(GraphHead.class, getAccumuloConfig())); graphCollection.getVertices() .output(new ElementOutputFormat<>(Vertex.class, getAccumuloConfig())); graphCollection.getEdges() .output(new ElementOutputFormat<>(Edge.class, getAccumuloConfig())); }
/** * {@inheritDoc} */ @Override public LogicalGraph getGraph(final GradoopId graphID) { // filter vertices and edges based on given graph id DataSet<GraphHead> graphHead = getGraphHeads() .filter(new BySameId<>(graphID)); DataSet<Vertex> vertices = getVertices() .filter(new InGraph<>(graphID)); DataSet<Edge> edges = getEdges() .filter(new InGraph<>(graphID)); return new LogicalGraph( config.getLogicalGraphFactory().fromDataSets(graphHead, vertices, edges), getConfig()); }
@Override public GraphCollection execute(GraphCollection collection) { DataSet<GraphHead> graphHeads = collection.getGraphHeads().first(limit); DataSet<GradoopId> firstIds = graphHeads.map(new Id<>()); DataSet<Vertex> filteredVertices = collection.getVertices() .filter(new InAnyGraphBroadcast<>()) .withBroadcastSet(firstIds, GraphsContainmentFilterBroadcast.GRAPH_IDS); DataSet<Edge> filteredEdges = collection.getEdges() .filter(new InAnyGraphBroadcast<>()) .withBroadcastSet(firstIds, GraphsContainmentFilterBroadcast.GRAPH_IDS); return collection.getConfig().getGraphCollectionFactory() .fromDataSets(graphHeads, filteredVertices, filteredEdges); }
@Override public GraphCollection execute(GraphCollection collection) { DataSet<GraphHead> graphHeads = collection.getGraphHeads().first(limit); DataSet<GradoopId> firstIds = graphHeads.map(new Id<>()); DataSet<Vertex> filteredVertices = collection.getVertices() .filter(new InAnyGraphBroadcast<>()) .withBroadcastSet(firstIds, GraphsContainmentFilterBroadcast.GRAPH_IDS); DataSet<Edge> filteredEdges = collection.getEdges() .filter(new InAnyGraphBroadcast<>()) .withBroadcastSet(firstIds, GraphsContainmentFilterBroadcast.GRAPH_IDS); return collection.getConfig().getGraphCollectionFactory() .fromDataSets(graphHeads, filteredVertices, filteredEdges); } }