Search in sources :

Example 1 with Result

use of org.apache.flink.graph.library.metric.directed.VertexMetrics.Result in project flink by apache.

the class VertexMetricsTest method testWithCompleteGraph.

@Test
public void testWithCompleteGraph() throws Exception {
    long expectedDegree = completeGraphVertexCount - 1;
    long expectedBidirectionalEdges = completeGraphVertexCount * expectedDegree / 2;
    long expectedMaximumTriplets = CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2);
    long expectedTriplets = completeGraphVertexCount * expectedMaximumTriplets;
    Result expectedResult = new Result(completeGraphVertexCount, 0, expectedBidirectionalEdges, expectedTriplets, expectedDegree, expectedDegree, expectedDegree, expectedMaximumTriplets);
    Result vertexMetrics = new VertexMetrics<LongValue, NullValue, NullValue>().run(completeGraph).execute();
    assertEquals(expectedResult, vertexMetrics);
    assertEquals(expectedDegree, vertexMetrics.getAverageDegree(), ACCURACY);
    assertEquals(1.0f, vertexMetrics.getDensity(), ACCURACY);
}
Also used : Result(org.apache.flink.graph.library.metric.directed.VertexMetrics.Result) Test(org.junit.Test)

Example 2 with Result

use of org.apache.flink.graph.library.metric.directed.VertexMetrics.Result in project flink by apache.

the class VertexMetricsTest method testWithEmptyGraph.

@Test
public void testWithEmptyGraph() throws Exception {
    Result expectedResult;
    expectedResult = new Result(0, 0, 0, 0, 0, 0, 0, 0);
    Result withoutZeroDegreeVertices = new VertexMetrics<LongValue, NullValue, NullValue>().setIncludeZeroDegreeVertices(false).run(emptyGraph).execute();
    assertEquals(expectedResult, withoutZeroDegreeVertices);
    assertEquals(Float.NaN, withoutZeroDegreeVertices.getAverageDegree(), ACCURACY);
    assertEquals(Float.NaN, withoutZeroDegreeVertices.getDensity(), ACCURACY);
    expectedResult = new Result(3, 0, 0, 0, 0, 0, 0, 0);
    Result withZeroDegreeVertices = new VertexMetrics<LongValue, NullValue, NullValue>().setIncludeZeroDegreeVertices(true).run(emptyGraph).execute();
    assertEquals(expectedResult, withZeroDegreeVertices);
    assertEquals(0.0f, withZeroDegreeVertices.getAverageDegree(), ACCURACY);
    assertEquals(0.0f, withZeroDegreeVertices.getDensity(), ACCURACY);
}
Also used : NullValue(org.apache.flink.types.NullValue) LongValue(org.apache.flink.types.LongValue) Result(org.apache.flink.graph.library.metric.directed.VertexMetrics.Result) Test(org.junit.Test)

Example 3 with Result

use of org.apache.flink.graph.library.metric.directed.VertexMetrics.Result in project flink by apache.

the class VertexMetricsTest method testWithRMatGraph.

@Test
public void testWithRMatGraph() throws Exception {
    Result expectedResult = new Result(902, 8875, 1567, 1003442, 463, 334, 342, 106953);
    Result withoutZeroDegreeVertices = new VertexMetrics<LongValue, NullValue, NullValue>().run(directedRMatGraph).execute();
    assertEquals(expectedResult, withoutZeroDegreeVertices);
}
Also used : Result(org.apache.flink.graph.library.metric.directed.VertexMetrics.Result) Test(org.junit.Test)

Example 4 with Result

use of org.apache.flink.graph.library.metric.directed.VertexMetrics.Result in project flink by apache.

the class VertexMetricsTest method testWithSimpleGraph.

@Test
public void testWithSimpleGraph() throws Exception {
    Result expectedResult = new Result(6, 7, 0, 13, 4, 2, 3, 6);
    Result vertexMetrics = new VertexMetrics<IntValue, NullValue, NullValue>().run(directedSimpleGraph).execute();
    assertEquals(expectedResult, vertexMetrics);
}
Also used : Result(org.apache.flink.graph.library.metric.directed.VertexMetrics.Result) Test(org.junit.Test)

Aggregations

Result (org.apache.flink.graph.library.metric.directed.VertexMetrics.Result)4 Test (org.junit.Test)4 LongValue (org.apache.flink.types.LongValue)1 NullValue (org.apache.flink.types.NullValue)1