use of org.apache.flink.graph.Edge in project flink by splunk.
the class GraphMutationsITCase method testRemoveInvalidVertex.
@Test
public void testRemoveInvalidVertex() throws Exception {
/*
* Test removeVertex() -- remove an invalid vertex
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
graph = graph.removeVertex(new Vertex<>(6L, 6L));
DataSet<Edge<Long, Long>> data = graph.getEdges();
List<Edge<Long, Long>> result = data.collect();
expectedResult = "1,2,12\n" + "1,3,13\n" + "2,3,23\n" + "3,4,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.graph.Edge in project flink by splunk.
the class SummarizationITCase method testWithVertexAndEdgeLongValues.
@Test
public void testWithVertexAndEdgeLongValues() throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> input = Graph.fromDataSet(SummarizationData.getVertices(env), SummarizationData.getEdges(env), env).run(new TranslateVertexValues<>(new StringToLong())).run(new TranslateEdgeValues<>(new StringToLong()));
List<Vertex<Long, Summarization.VertexValue<Long>>> summarizedVertices = new ArrayList<>();
List<Edge<Long, EdgeValue<Long>>> summarizedEdges = new ArrayList<>();
Graph<Long, Summarization.VertexValue<Long>, EdgeValue<Long>> output = input.run(new Summarization<>());
output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));
env.execute();
validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
validateEdges(SummarizationData.EXPECTED_EDGES_WITH_VALUES, summarizedEdges);
}
use of org.apache.flink.graph.Edge in project flink by splunk.
the class IncrementalSSSPITCase method testIncrementalSSSPNonSPEdge.
@Test
public void testIncrementalSSSPNonSPEdge() throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Vertex<Long, Double>> vertices = IncrementalSSSPData.getDefaultVertexDataSet(env);
DataSet<Edge<Long, Double>> edges = IncrementalSSSPData.getDefaultEdgeDataSet(env);
DataSet<Edge<Long, Double>> edgesInSSSP = IncrementalSSSPData.getDefaultEdgesInSSSP(env);
// the edge to be removed is a non-SP edge
Edge<Long, Double> edgeToBeRemoved = new Edge<>(3L, 5L, 5.0);
Graph<Long, Double, Double> graph = Graph.fromDataSet(vertices, edges, env);
// Assumption: all minimum weight paths are kept
Graph<Long, Double, Double> ssspGraph = Graph.fromDataSet(vertices, edgesInSSSP, env);
// remove the edge
graph.removeEdge(edgeToBeRemoved);
// configure the iteration
ScatterGatherConfiguration parameters = new ScatterGatherConfiguration();
if (IncrementalSSSP.isInSSSP(edgeToBeRemoved, edgesInSSSP)) {
parameters.setDirection(EdgeDirection.IN);
parameters.setOptDegrees(true);
// run the scatter gather iteration to propagate info
Graph<Long, Double, Double> result = ssspGraph.runScatterGatherIteration(new IncrementalSSSP.InvalidateMessenger(edgeToBeRemoved), new IncrementalSSSP.VertexDistanceUpdater(), IncrementalSSSPData.NUM_VERTICES, parameters);
DataSet<Vertex<Long, Double>> resultedVertices = result.getVertices();
resultedVertices.writeAsCsv(resultPath, "\n", ",");
env.execute();
} else {
vertices.writeAsCsv(resultPath, "\n", ",");
env.execute();
}
expected = IncrementalSSSPData.VERTICES;
}
use of org.apache.flink.graph.Edge in project flink by splunk.
the class SummarizationITCase method testWithVertexAndEdgeStringValues.
@Test
public void testWithVertexAndEdgeStringValues() throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, String, String> input = Graph.fromDataSet(SummarizationData.getVertices(env), SummarizationData.getEdges(env), env);
List<Vertex<Long, Summarization.VertexValue<String>>> summarizedVertices = new ArrayList<>();
List<Edge<Long, EdgeValue<String>>> summarizedEdges = new ArrayList<>();
Graph<Long, Summarization.VertexValue<String>, EdgeValue<String>> output = input.run(new Summarization<>());
output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));
env.execute();
validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
validateEdges(SummarizationData.EXPECTED_EDGES_WITH_VALUES, summarizedEdges);
}
use of org.apache.flink.graph.Edge in project flink by splunk.
the class SummarizationITCase method testWithVertexAndAbsentEdgeStringValues.
@Test
public void testWithVertexAndAbsentEdgeStringValues() throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, String, NullValue> input = Graph.fromDataSet(SummarizationData.getVertices(env), SummarizationData.getEdges(env), env).run(new TranslateEdgeValues<>(new ToNullValue<>()));
List<Vertex<Long, Summarization.VertexValue<String>>> summarizedVertices = new ArrayList<>();
List<Edge<Long, EdgeValue<NullValue>>> summarizedEdges = new ArrayList<>();
Graph<Long, Summarization.VertexValue<String>, EdgeValue<NullValue>> output = input.run(new Summarization<>());
output.getVertices().output(new LocalCollectionOutputFormat<>(summarizedVertices));
output.getEdges().output(new LocalCollectionOutputFormat<>(summarizedEdges));
env.execute();
validateVertices(SummarizationData.EXPECTED_VERTICES, summarizedVertices);
validateEdges(SummarizationData.EXPECTED_EDGES_ABSENT_VALUES, summarizedEdges);
}
Aggregations