use of org.apache.flink.graph.Edge in project flink by apache.
the class EdgeTargetDegreesTest method testWithRMatGraph.
@Test
public void testWithRMatGraph() throws Exception {
DataSet<Edge<LongValue, Tuple2<NullValue, Degrees>>> targetDegrees = directedRMatGraph.run(new EdgeTargetDegrees<LongValue, NullValue, NullValue>());
Checksum checksum = new ChecksumHashCode<Edge<LongValue, Tuple2<NullValue, Degrees>>>().run(targetDegrees).execute();
assertEquals(12009, checksum.getCount());
assertEquals(0x0000160af450cc81L, checksum.getChecksum());
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class EdgeDegreePairTest method testWithRMatGraph.
@Test
public void testWithRMatGraph() throws Exception {
DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnSourceId = undirectedRMatGraph.run(new EdgeDegreePair<LongValue, NullValue, NullValue>());
Checksum checksumOnSourceId = new ChecksumHashCode<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>>().run(degreePairOnSourceId).execute();
assertEquals(20884, checksumOnSourceId.getCount());
assertEquals(0x00000001e051efe4L, checksumOnSourceId.getChecksum());
DataSet<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>> degreePairOnTargetId = undirectedRMatGraph.run(new EdgeDegreePair<LongValue, NullValue, NullValue>().setReduceOnTargetId(true));
Checksum checksumOnTargetId = new ChecksumHashCode<Edge<LongValue, Tuple3<NullValue, LongValue, LongValue>>>().run(degreePairOnTargetId).execute();
assertEquals(checksumOnSourceId, checksumOnTargetId);
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class ConnectedComponentsWithRandomisedEdgesITCase method testProgram.
@Override
protected void testProgram() throws Exception {
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
DataSet<Long> vertexIds = env.generateSequence(1, NUM_VERTICES);
DataSet<String> edgeString = env.fromElements(ConnectedComponentsData.getRandomOddEvenEdges(NUM_EDGES, NUM_VERTICES, SEED).split("\n"));
DataSet<Edge<Long, NullValue>> edges = edgeString.map(new EdgeParser());
DataSet<Vertex<Long, Long>> initialVertices = vertexIds.map(new IdAssigner());
Graph<Long, Long, NullValue> graph = Graph.fromDataSet(initialVertices, edges, env);
DataSet<Vertex<Long, Long>> result = graph.run(new ConnectedComponents<Long, Long, NullValue>(100));
result.writeAsCsv(resultPath, "\n", " ");
env.execute();
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class FromCollectionITCase method testFromCollectionVerticesEdges.
@Test
public void testFromCollectionVerticesEdges() throws Exception {
/*
* Test fromCollection(vertices, edges):
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env);
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 apache.
the class SimplifyTest method setup.
@Before
public void setup() {
ExecutionEnvironment env = ExecutionEnvironment.createCollectionsEnvironment();
Object[][] edges = new Object[][] { new Object[] { 0, 0 }, new Object[] { 0, 1 }, new Object[] { 0, 1 }, new Object[] { 0, 2 }, new Object[] { 0, 2 }, new Object[] { 1, 0 }, new Object[] { 2, 2 } };
List<Edge<IntValue, NullValue>> edgeList = new LinkedList<>();
for (Object[] edge : edges) {
edgeList.add(new Edge<>(new IntValue((int) edge[0]), new IntValue((int) edge[1]), NullValue.getInstance()));
}
graph = Graph.fromCollection(edgeList, env);
}
Aggregations