Skip to content
Permalink
Browse files

[dbs-leipzig#1263] Generify Exclusion, Combination, Overlap

and their interface
and move some to base graph
  • Loading branch information...
timo95 committed May 15, 2019
1 parent 35200d8 commit 4eedb18b272c22645549727fc56ac2dbc92aa857
Showing with 408 additions and 379 deletions.
  1. +101 −1 gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraph.java
  2. +222 −0 gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/BaseGraphOperators.java
  3. +2 −2 gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/GraphCollectionOperators.java
  4. +4 −192 gradoop-flink/src/main/java/org/gradoop/flink/model/api/epgm/LogicalGraphOperators.java
  5. +5 −17 ...k/model/api/operators/{BinaryGraphToGraphOperator.java → BinaryBaseGraphToBaseGraphOperator.java}
  6. +8 −9 ...flink/model/api/operators/{BinaryGraphToValueOperator.java → BinaryBaseGraphToValueOperator.java}
  7. +1 −1 ...link/src/main/java/org/gradoop/flink/model/api/operators/ReducibleBinaryGraphToGraphOperator.java
  8. +1 −1 ...-flink/src/main/java/org/gradoop/flink/model/api/operators/UnaryBaseGraphToBaseGraphOperator.java
  9. +8 −100 gradoop-flink/src/main/java/org/gradoop/flink/model/impl/epgm/LogicalGraph.java
  10. +0 −2 gradoop-flink/src/main/java/org/gradoop/flink/model/impl/functions/epgm/ElementIdUpdater.java
  11. +6 −2 gradoop-flink/src/main/java/org/gradoop/flink/model/impl/operators/cloning/Cloning.java
  12. +17 −14 gradoop-flink/src/main/java/org/gradoop/flink/model/impl/operators/combination/Combination.java
  13. +3 −2 gradoop-flink/src/main/java/org/gradoop/flink/model/impl/operators/equality/GraphEquality.java
  14. +13 −22 gradoop-flink/src/main/java/org/gradoop/flink/model/impl/operators/exclusion/Exclusion.java
  15. +2 −2 gradoop-flink/src/main/java/org/gradoop/flink/model/impl/operators/fusion/VertexFusion.java
  16. +15 −12 gradoop-flink/src/main/java/org/gradoop/flink/model/impl/operators/overlap/Overlap.java
@@ -15,12 +15,26 @@
*/
package org.gradoop.flink.model.api.epgm;

import org.apache.flink.api.common.functions.FilterFunction;
import org.gradoop.common.model.api.entities.EPGMEdge;
import org.gradoop.common.model.api.entities.EPGMGraphHead;
import org.gradoop.common.model.api.entities.EPGMVertex;
import org.gradoop.flink.model.api.functions.AggregateFunction;
import org.gradoop.flink.model.api.functions.TransformationFunction;
import org.gradoop.flink.model.api.layouts.LogicalGraphLayout;
import org.gradoop.flink.model.impl.epgm.LogicalGraph;
import org.gradoop.flink.model.impl.operators.aggregation.Aggregation;
import org.gradoop.flink.model.impl.operators.cloning.Cloning;
import org.gradoop.flink.model.impl.operators.combination.Combination;
import org.gradoop.flink.model.impl.operators.exclusion.Exclusion;
import org.gradoop.flink.model.impl.operators.overlap.Overlap;
import org.gradoop.flink.model.impl.operators.subgraph.Subgraph;
import org.gradoop.flink.model.impl.operators.transformation.Transformation;
import org.gradoop.flink.model.impl.operators.verify.Verify;
import org.gradoop.flink.util.GradoopFlinkConfig;

import java.util.Objects;

/**
* Default interface of a EPGM logical graph instance.
*
@@ -33,7 +47,8 @@
G extends EPGMGraphHead,
V extends EPGMVertex,
E extends EPGMEdge,
LG extends BaseGraph<G, V, E, LG>> extends LogicalGraphLayout<G, V, E> {
LG extends BaseGraph<G, V, E, LG>>
extends LogicalGraphLayout<G, V, E>, BaseGraphOperators<G, V, E, LG> {
/**
* Returns the Gradoop Flink configuration.
*
@@ -52,4 +67,89 @@
// Unary Operators
//----------------------------------------------------------------------------

@Override
default LG copy() {
return callForGraph(new Cloning<>());
}

@Override
default LG transform(
TransformationFunction<G> graphHeadTransformationFunction,
TransformationFunction<V> vertexTransformationFunction,
TransformationFunction<E> edgeTransformationFunction) {
return callForGraph(new Transformation<>(
graphHeadTransformationFunction,
vertexTransformationFunction,
edgeTransformationFunction));
}

@Override
default LG transformGraphHead(
TransformationFunction<G> graphHeadTransformationFunction) {
return transform(graphHeadTransformationFunction, null, null);
}

@Override
default LG transformVertices(
TransformationFunction<V> vertexTransformationFunction) {
return transform(null, vertexTransformationFunction, null);
}

@Override
default LG transformEdges(
TransformationFunction<E> edgeTransformationFunction) {
return transform(null, null, edgeTransformationFunction);
}

@Override
default LG vertexInducedSubgraph(
FilterFunction<V> vertexFilterFunction) {
Objects.requireNonNull(vertexFilterFunction);
return callForGraph(
new Subgraph<>(vertexFilterFunction, null, Subgraph.Strategy.VERTEX_INDUCED));
}

@Override
default LG edgeInducedSubgraph(
FilterFunction<E> edgeFilterFunction) {
Objects.requireNonNull(edgeFilterFunction);
return callForGraph(new Subgraph<>(null, edgeFilterFunction, Subgraph.Strategy.EDGE_INDUCED));
}

@Override
default LG subgraph(
FilterFunction<V> vertexFilterFunction,
FilterFunction<E> edgeFilterFunction, Subgraph.Strategy strategy) {
return callForGraph(new Subgraph<>(vertexFilterFunction, edgeFilterFunction, strategy));
}

@Override
default LG aggregate(AggregateFunction... aggregateFunctions) {
return callForGraph(new Aggregation<>(aggregateFunctions));
}

@Override
default LG verify() {
return callForGraph(new Verify<>());
}

//----------------------------------------------------------------------------
// Binary Operators
//----------------------------------------------------------------------------

@Override
default LG combine(LG otherGraph) {
return callForGraph(new Combination<>(), otherGraph);
}

@Override
default LG overlap(LG otherGraph) {
return callForGraph(new Overlap<>(), otherGraph);
}

@Override
default LG exclude(LG otherGraph) {
return callForGraph(new Exclusion<>(), otherGraph);
}

}
@@ -0,0 +1,222 @@
/*
* Copyright © 2014 - 2019 Leipzig University (Database Research Group)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradoop.flink.model.api.epgm;

import org.apache.flink.api.common.functions.FilterFunction;
import org.gradoop.common.model.api.entities.EPGMEdge;
import org.gradoop.common.model.api.entities.EPGMGraphHead;
import org.gradoop.common.model.api.entities.EPGMVertex;
import org.gradoop.flink.model.api.functions.AggregateFunction;
import org.gradoop.flink.model.api.functions.TransformationFunction;
import org.gradoop.flink.model.api.operators.BinaryBaseGraphToBaseGraphOperator;
import org.gradoop.flink.model.api.operators.UnaryBaseGraphToBaseGraphOperator;
import org.gradoop.flink.model.impl.operators.subgraph.Subgraph;

import java.util.Objects;

/**
* Defines the operators that are available on a {@link BaseGraph}.
*
* @param <G> type of the graph head
* @param <V> the vertex type
* @param <E> the edge type
* @param <LG> the type of the logical graph
*/
public interface BaseGraphOperators<
G extends EPGMGraphHead,
V extends EPGMVertex,
E extends EPGMEdge,
LG extends BaseGraph<G, V, E, LG>> {

//----------------------------------------------------------------------------
// Unary Operators
//----------------------------------------------------------------------------

/**
* Creates a copy of the logical graph.
* <p>
* Note that this method creates new graph head, vertex and edge instances.
*
* @return projected logical graph
*/
LG copy();

/**
* Transforms the elements of the logical graph using the given transformation functions.
* The identity of the elements is preserved.
*
* @param graphHeadTransformationFunction graph head transformation function
* @param vertexTransformationFunction vertex transformation function
* @param edgeTransformationFunction edge transformation function
* @return transformed logical graph
*/
LG transform(
TransformationFunction<G> graphHeadTransformationFunction,
TransformationFunction<V> vertexTransformationFunction,
TransformationFunction<E> edgeTransformationFunction);

/**
* Transforms the graph head of the logical graph using the given
* transformation function. The identity of the graph is preserved.
*
* @param graphHeadTransformationFunction graph head transformation function
* @return transformed logical graph
*/
LG transformGraphHead(
TransformationFunction<G> graphHeadTransformationFunction);

/**
* Transforms the vertices of the logical graph using the given transformation
* function. The identity of the vertices is preserved.
*
* @param vertexTransformationFunction vertex transformation function
* @return transformed logical graph
*/
LG transformVertices(TransformationFunction<V> vertexTransformationFunction);

/**
* Transforms the edges of the logical graph using the given transformation function.
* The identity of the edges is preserved.
*
* @param edgeTransformationFunction edge transformation function
* @return transformed logical graph
*/
LG transformEdges(TransformationFunction<E> edgeTransformationFunction);

/**
* Returns the subgraph that is induced by the vertices which fulfill the given filter function.
*
* @param vertexFilterFunction vertex filter function
* @return vertex-induced subgraph as a new logical graph
*/
LG vertexInducedSubgraph(FilterFunction<V> vertexFilterFunction);

/**
* Returns the subgraph that is induced by the edges which fulfill the given filter function.
*
* @param edgeFilterFunction edge filter function
* @return edge-induced subgraph as a new logical graph
*/
LG edgeInducedSubgraph(FilterFunction<E> edgeFilterFunction);

/**
* Returns a subgraph of the logical graph which contains only those vertices
* and edges that fulfil the given vertex and edge filter function respectively.
* <p>
* Note, that the operator does not verify the consistency of the resulting
* graph. Use {#toGellyGraph().subgraph()} for that behaviour.
*
* @param vertexFilterFunction vertex filter function
* @param edgeFilterFunction edge filter function
* @return logical graph which fulfils the given predicates and is a subgraph
* of that graph
*/
default LG subgraph(FilterFunction<V> vertexFilterFunction,
FilterFunction<E> edgeFilterFunction) {
Objects.requireNonNull(vertexFilterFunction);
Objects.requireNonNull(edgeFilterFunction);
return subgraph(vertexFilterFunction, edgeFilterFunction, Subgraph.Strategy.BOTH);
}

/**
* Returns a subgraph of the logical graph which contains only those vertices
* and edges that fulfil the given vertex and edge filter function respectively.
* <p>
* Note, that the operator does not verify the consistency of the resulting
* graph. Use {#toGellyGraph().subgraph()} for that behaviour.
*
* @param vertexFilterFunction vertex filter function
* @param edgeFilterFunction edge filter function
* @param strategy execution strategy for the operator
* @return logical graph which fulfils the given predicates and is a subgraph
* of that graph
*/
LG subgraph(FilterFunction<V> vertexFilterFunction,
FilterFunction<E> edgeFilterFunction, Subgraph.Strategy strategy);

/**
* Applies the given aggregate functions to the logical graph and stores the
* result of those functions at the resulting graph using the given property keys.
*
* @param aggregateFunctions computes aggregates on the logical graph
* @return logical graph with additional properties storing the aggregates
*/
LG aggregate(AggregateFunction... aggregateFunctions);

/**
* Verifies this graph, removing dangling edges, i.e. edges pointing to or from
* a vertex not contained in this graph.<br>
* This operator can be applied after an operator that has not checked the graphs validity.
* The graph head of this logical graph remains unchanged.
*
* @return this graph with all dangling edges removed.
*/
LG verify();

//----------------------------------------------------------------------------
// Binary Operators
//----------------------------------------------------------------------------

/**
* Creates a new logical graph by combining the vertex and edge sets of
* this graph and the given graph. Vertex and edge equality is based on their identifiers.
*
* @param otherGraph logical graph to combine this graph with
* @return logical graph containing all vertices and edges of the input graphs
*/
LG combine(LG otherGraph);

/**
* Creates a new logical graph containing the overlapping vertex and edge sets of this graph
* and the given graph. Vertex and edge equality is based on their identifiers.
*
* @param otherGraph logical graph to compute overlap with
* @return logical graph that contains all vertices and edges that exist in
* both input graphs
*/
LG overlap(LG otherGraph);

/**
* Creates a new logical graph containing only vertices and edges that
* exist in that graph but not in the other graph. Vertex and edge equality
* is based on their identifiers.
*
* @param otherGraph logical graph to exclude from that graph
* @return logical that contains only vertices and edges that are not in the other graph
*/
LG exclude(LG otherGraph);

//----------------------------------------------------------------------------
// Auxiliary Operators
//----------------------------------------------------------------------------

/**
* Creates a logical graph using the given unary graph operator.
*
* @param operator unary graph to graph operator
* @return result of given operator
*/
LG callForGraph(UnaryBaseGraphToBaseGraphOperator<LG> operator);

/**
* Creates a logical graph from that graph and the input graph using the given binary operator.
*
* @param operator binary graph to graph operator
* @param otherGraph other graph
* @return result of given operator
*/
LG callForGraph(BinaryBaseGraphToBaseGraphOperator<LG> operator, LG otherGraph);
}
@@ -23,8 +23,8 @@
import org.gradoop.common.util.Order;
import org.gradoop.flink.model.api.functions.GraphHeadReduceFunction;
import org.gradoop.flink.model.api.operators.ApplicableUnaryGraphToGraphOperator;
import org.gradoop.flink.model.api.operators.BinaryBaseGraphToBaseGraphOperator;
import org.gradoop.flink.model.api.operators.BinaryCollectionToCollectionOperator;
import org.gradoop.flink.model.api.operators.BinaryGraphToGraphOperator;
import org.gradoop.flink.model.api.operators.ReducibleBinaryGraphToGraphOperator;
import org.gradoop.flink.model.api.operators.UnaryCollectionToCollectionOperator;
import org.gradoop.flink.model.api.operators.UnaryCollectionToGraphOperator;
@@ -265,7 +265,7 @@ GraphCollection apply(

/**
* Transforms a graph collection into a logical graph by applying a
* {@link BinaryGraphToGraphOperator} pairwise on the elements of the
* {@link BinaryBaseGraphToBaseGraphOperator} pairwise on the elements of the
* collection.
*
* @param op reducible binary graph to graph operator

0 comments on commit 4eedb18

Please sign in to comment.
You can’t perform that action at this time.