Search in sources :

Example 51 with Edge

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());
}
Also used : NullValue(org.apache.flink.types.NullValue) Degrees(org.apache.flink.graph.asm.degree.annotate.directed.VertexDegrees.Degrees) Checksum(org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum) Tuple2(org.apache.flink.api.java.tuple.Tuple2) LongValue(org.apache.flink.types.LongValue) ChecksumHashCode(org.apache.flink.graph.asm.dataset.ChecksumHashCode) Edge(org.apache.flink.graph.Edge) Test(org.junit.Test)

Example 52 with Edge

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);
}
Also used : NullValue(org.apache.flink.types.NullValue) Checksum(org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum) Tuple3(org.apache.flink.api.java.tuple.Tuple3) LongValue(org.apache.flink.types.LongValue) ChecksumHashCode(org.apache.flink.graph.asm.dataset.ChecksumHashCode) Edge(org.apache.flink.graph.Edge) Test(org.junit.Test)

Example 53 with Edge

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();
}
Also used : Vertex(org.apache.flink.graph.Vertex) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) NullValue(org.apache.flink.types.NullValue) Edge(org.apache.flink.graph.Edge)

Example 54 with Edge

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);
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Edge(org.apache.flink.graph.Edge) Test(org.junit.Test)

Example 55 with Edge

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);
}
Also used : ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) Edge(org.apache.flink.graph.Edge) IntValue(org.apache.flink.types.IntValue) LinkedList(java.util.LinkedList) Before(org.junit.Before)

Aggregations

Edge (org.apache.flink.graph.Edge)82 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)70 Test (org.junit.Test)66 Vertex (org.apache.flink.graph.Vertex)39 NullValue (org.apache.flink.types.NullValue)18 ArrayList (java.util.ArrayList)14 LongValue (org.apache.flink.types.LongValue)13 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)11 MapFunction (org.apache.flink.api.common.functions.MapFunction)6 ChecksumHashCode (org.apache.flink.graph.asm.dataset.ChecksumHashCode)6 Checksum (org.apache.flink.graph.asm.dataset.ChecksumHashCode.Checksum)6 LinkedList (java.util.LinkedList)5 Plan (org.apache.flink.api.common.Plan)5 FieldList (org.apache.flink.api.common.operators.util.FieldList)5 DataSet (org.apache.flink.api.java.DataSet)5 DiscardingOutputFormat (org.apache.flink.api.java.io.DiscardingOutputFormat)5 Graph (org.apache.flink.graph.Graph)5 Tuple2ToVertexMap (org.apache.flink.graph.utils.Tuple2ToVertexMap)5 DualInputPlanNode (org.apache.flink.optimizer.plan.DualInputPlanNode)5 OptimizedPlan (org.apache.flink.optimizer.plan.OptimizedPlan)5