Skip to content

Data Integration Operators

Christopher Rost edited this page Jan 3, 2020 · 7 revisions

This section provides an overview of the operators the Data Integration Module delivers. After the graph data got imported with the provided GradoopDataSources all the following graph transformation can help to bring the data structure into the required shape.

Operators
VertexToEdge
EdgeToVertex
ConnectNeighbors
VertexDeduplication
ExtractPropertyFromVertex
PropagatePropertyToNeighbor
InvertEdges

VertexToEdge

This graph transformation turns vertices into edges using the following steps:

  1. Take all neighbors of a vertex matching the given label and calculate the transitive closure for this subgraph
  2. Any new edge in the transitive closure gets the given newEdgeLabel
  3. The originalVertexLabel, the firstEdgeLabel (label of the edge pointing on the vertex) and the secondEdgeLabel (label of the edge pointing away from the vertex) get set as a PropertyValue of the new edge

The original vertices are still part of the resulting graph. To delete them, use a FilterFunction.

VertexToEdge Example

LogicalGraph input = (...)
VertexToEdge vertexToEdge = new VertexToEdge("Message", "Writes Message To");
LogicalGraph transformed = input.callForGraph(vertexToEdge);

input: transformed:


EdgeToVertex

For edges of a specific edgeLabel this graph transformation creates a new vertex containing the properties of the edge and two new edges respecting the direction of the original edge. The newly created edges and vertex labels are user-defined (newVertexLabel, edgeLabelSourceToNew, edgeLabelNewToTarget). The original edges are still part of the resulting graph. Use a FilterFunction on the original label to remove them.

EdgeToVertex Example

LogicalGraph input = (...)
EdgeToVertex edgeToVertex = new EdgeToVertex("Message", "Message", "writes", "to");
LogicalGraph transformed = input.callForGraph(edgeToVertex);

input: transformed:


ConnectNeighbors

This graph transformation adds new edges to the graph. Those edges are created if a vertex of a user-defined label has two neighbors of another user-defined label. A bidirectional (two edges in Gradoop) edge is then created between those two neighbors.

Parameters Description
String sourceVertexLabel The label of the vertices the neighborhood is connected with
EdgeDirection edgeDirection The edge direction to consider: Neighborhood.EdgeDirection.INCOMING, Neighborhood.EdgeDirection.OUTGOING or Neighborhood.EdgeDirection.UNDIRECTED if both direction should be taken into account
String neighborhoodVertexLabel The label of the neighboring vertices that should be connected
String newEdgeLabel The label of the created edge between the neighbors

ConnectNeighbors Example The code bellow connects all neighbors of vertices with the label "Message" of an imaginary graph with a new edge labeled "are in contact", if both neighbor vertices are labeled "Person".

LogicalGraph input = (...)
UnaryGraphToGraphOperator connectNeighbors = new ConnectNeighbors("Message", Neighborhood.EdgeDirection.INCOMING, "Person", "are in contact");
LogicalGraph transformed = input.callForGraph(connectNeighbors);

VertexDeduplication

This unary graph operator deduplicates vertices based on some attributes. Given a label and a list of property keys, this operator will find all vertices of that label and condense duplicates to one vertex. Two (or more) vertices are considered duplicates if all property values, respective to the list of given keys, are equal. Other attributes of the vertices are ignored, the new (condensed) vertex will have the attributes of some (random) vertex of its duplicates. This will create no new elements and retain the graph head.

VertexDeduplication Example The code shown bellow will delete all vertices of the input graph with the label "a" and the property keys "key" and "key2" except one random vector with these specs.

LogicalGraph input = (...)
LogicalGraph transformed = input.callForGraph(new VertexDeduplication<>("a", Arrays.asList("key", "key2")));

ExtractPropertyFromVertex

This operator is executed on the vertex dataset and extracts a property to a newly created vertex which can be connected to the vertex it was created from. If the property is a list every element of the list is a new vertex.

Parameters Description
String forVerticesOfLabel The label of the vertices containing the property value which should get extracted
String originalPropertyName The property key for this value
String newVertexLabel The label of the new vertex
String newPropertyName The new property key for the extracted value
EdgeDirection edgeDirection The direction of the created edge(s): EdgeDirection.ORIGIN_TO_NEWVERTEX, EdgeDirection.NEWVERTEX_TO_ORIGIN or EdgeDirection.BIDIRECTIONAL if both directions should be created
String edgeLabel The label of the newly created edge
Boolean condense (not a constructor parameter, settable via the .setCondensation(boolean condense) method If true, every equal property value get condensed so that every newly created vector contains a unique property value

ExtractPropertyFromVertex Example The code below extracts the property "capital" of every vertex contained in the imaginary input graph with the label "country" into the "name" property of newly created vertices labeled "city".

LogicalGraph input = (...)
ExtractPropertyFromVertex extract = new ExtractPropertyFromVertex("Country", "capital","city", "name");
LogicalGraph transformed = input.callForGraph(extract);

This code fragment does the same as the above example but creates an edge in addition labeled "isCapitalOf" pointing from the newly created "capital" vertex to the "country" vertex.

LogicalGraph input = (...)
ExtractPropertyFromVertex extract = new ExtractPropertyFromVertex("Country", "capital", "city", "name", EdgeDirection.NEWVERTEX_TO_ORIGIN, "isCapitalOf");
LogicalGraph transformed = input.callForGraph(extract);

PropagatePropertyToNeighbor

Operator to propagate a property of vertices with a given label to their neighbors and aggregate it in their PropertyLists.

Parameters Description
String vertexLabel The label of the vertex which contains the propertyValue for the propagation
String propertyKey The key of the propertyValue to propagate
String targetVertexPropertyKey The property key where the PropertyValue list should be stored at the target vertices.

SetpropagatingEdges | Only edges with the inserted labels are used; If all labels are sufficient use null SettargetVertexLabels | Only vertices with the inserted labels will store the propagated values; If all vertices should be considered use null

PropagatePropertyToNeighbor Example In the code fragment below the PropagatePropertyToNeighbor operator searches for vertices with the label "a" in the input graph and copies the PropertyValue which is stored under the key "color" into all adjacent vertices using the new PropertyKey "newColor".

LogicalGraph input = (...)
PropagatePropertyToNeighbor pPtN = new PropagatePropertyToNeighbor("a", "color", "newColor");
LogicalGraph transformed = input.callForGraph(pPtN);

In this example, the property "color" gets propagated from every vertex labeled "a" to any neighboring vertex labeled "b". Again the PropertyValue is stored with the key "newColor".

LogicalGraph input = (...)
PropagatePropertyToNeighbor pPtN = new PropagatePropertyToNeighbor("a", "color", "newColor", null, Collections.singleton("b"));
LogicalGraph transformed = input.callForGraph(pPtN);

InvertEdges

An edge transformation function that swaps the source and target of an edge with a given label and renames it.

Parameter Description
String forEdgeLabel The label of the edges which should be inverted
String newLabel The new label of the edge

InvertEdges Example The code fragment shown below switches the direction of every edge labeled "isCapitalOf" of an imaginary graph "input". As a logical result, we now rename the label of these edges into "hasCapital".

LogicalGraph input = (...)
InvertEdges invertEdges = new InvertEdges("isCapitalOf", "hasCapital");
LogicalGraph transformed = input.transformEdges(invertEdges);