Skip to content

Unary Graph Collection Operators

Rascat edited this page Aug 14, 2018 · 9 revisions

This section provides an overview of unary graph collection operators, which operate on a single GraphCollection and return a subset or transformation of the input collection.

Unary Graph Collection Operators
Selection
Matching
Limit
Distinct

Selection

Given a collection, the select operator filters all contained graphs based on their associated graph head and return a collection with logical graphs that fulfill the predicate.

Method Expects Returns
select predicate function (FilterFunction<GraphHead>) for a graph head GraphCollection which contains all logical graphs that fulfill the predicate.

Selection example

Consider the Social Network example graph, which contains multiple logical graphs with different relations. This example takes a single graph collection and selects a subset of logical graphs that fulfill the predicate function.
In order to select all graphs that contain edges labeled 'hasMember', we would do the following:

FlinkAsciiGraphLoader loader = getSocialNetworkLoader();

GraphCollection collection = loader.getGraphCollectionByVariables("g0", "g1", "g2", "g3");

// In order to select graphs that contain a certain edge label (in this case, 'hasMember'),
// we need to aggregate a property 'hasEdgeLabel_<label>' to determine if a give label is present or not.
// Since aggregated properties are added to the graph head, it is then possible
// to use the select method to retrieve graphs which are of interest to us.
HasEdgeLabel hasLabelHasMember = new HasEdgeLabel("hasMember"):

// apply aggregation
collection = collection.apply(new ApplyAggregation(hasLabelHasMember))

// select graphs
GraphCollection result = collection.select(hasLabelHasMember))

The graph collection result now contains the logical graph g3:Forum, since it is the only one which contains edges labeled 'hasMember'. Or to be more precise: it is the only one with a property 'hasEdgeLabel_hasMember' that is set to true after we applied the aggregation.

Matching

tbd.

Limit

tbd.

Distinct

tbd.