org.apache.flink.graph.library.clustering.undirected.LocalClusteringCoefficient.Result Java Examples
The following examples show how to use
org.apache.flink.graph.library.clustering.undirected.LocalClusteringCoefficient.Result.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalClusteringCoefficientTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSimpleGraph() throws Exception { String expectedResult = "(0,2,1)\n" + "(1,3,2)\n" + "(2,3,2)\n" + "(3,4,1)\n" + "(4,1,0)\n" + "(5,1,0)"; DataSet<Result<IntValue>> cc = undirectedSimpleGraph .run(new LocalClusteringCoefficient<>()); TestBaseUtils.compareResultAsText(cc.collect(), expectedResult); }
Example #2
Source File: LocalClusteringCoefficientTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testRMatGraph() throws Exception { DataSet<Result<LongValue>> cc = undirectedRMatGraph(10, 16) .run(new LocalClusteringCoefficient<>()); Checksum checksum = new ChecksumHashCode<Result<LongValue>>() .run(cc) .execute(); assertEquals(902, checksum.getCount()); assertEquals(0x000001cab2d3677bL, checksum.getChecksum()); }
Example #3
Source File: LocalClusteringCoefficientTest.java From flink with Apache License 2.0 | 5 votes |
/** * Validate a test where each result has the same values. * * @param graph input graph * @param count number of results * @param degree result degree * @param triangleCount result triangle count * @param <T> graph ID type * @throws Exception on error */ private static <T extends Comparable<T> & CopyableValue<T>> void validate( Graph<T, NullValue, NullValue> graph, long count, long degree, long triangleCount) throws Exception { DataSet<Result<T>> cc = graph .run(new LocalClusteringCoefficient<>()); List<Result<T>> results = cc.collect(); assertEquals(count, results.size()); for (Result<T> result : results) { assertEquals(degree, result.getDegree().getValue()); assertEquals(triangleCount, result.getTriangleCount().getValue()); } }
Example #4
Source File: LocalClusteringCoefficientTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSimpleGraph() throws Exception { String expectedResult = "(0,2,1)\n" + "(1,3,2)\n" + "(2,3,2)\n" + "(3,4,1)\n" + "(4,1,0)\n" + "(5,1,0)"; DataSet<Result<IntValue>> cc = undirectedSimpleGraph .run(new LocalClusteringCoefficient<>()); TestBaseUtils.compareResultAsText(cc.collect(), expectedResult); }
Example #5
Source File: LocalClusteringCoefficient.java From flink with Apache License 2.0 | 5 votes |
@Override public Result<T> join(Vertex<T, LongValue> vertexAndDegree, Tuple2<T, LongValue> vertexAndTriangleCount) throws Exception { output.setVertexId0(vertexAndDegree.f0); output.setDegree(vertexAndDegree.f1); output.setTriangleCount((vertexAndTriangleCount == null) ? zero : vertexAndTriangleCount.f1); return output; }
Example #6
Source File: LocalClusteringCoefficient.java From flink with Apache License 2.0 | 5 votes |
@Override public void flatMap(TriangleListing.Result<T> value, Collector<Tuple2<T, LongValue>> out) throws Exception { output.f0 = value.getVertexId0(); out.collect(output); output.f0 = value.getVertexId1(); out.collect(output); output.f0 = value.getVertexId2(); out.collect(output); }
Example #7
Source File: LocalClusteringCoefficient.java From flink with Apache License 2.0 | 5 votes |
@Override public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input) throws Exception { // u, v, w DataSet<TriangleListing.Result<K>> triangles = input .run(new TriangleListing<K, VV, EV>() .setParallelism(parallelism)); // u, 1 DataSet<Tuple2<K, LongValue>> triangleVertices = triangles .flatMap(new SplitTriangles<>()) .name("Split triangle vertices"); // u, triangle count DataSet<Tuple2<K, LongValue>> vertexTriangleCount = triangleVertices .groupBy(0) .reduce(new CountTriangles<>()) .setCombineHint(CombineHint.HASH) .name("Count triangles") .setParallelism(parallelism); // u, deg(u) DataSet<Vertex<K, LongValue>> vertexDegree = input .run(new VertexDegree<K, VV, EV>() .setIncludeZeroDegreeVertices(includeZeroDegreeVertices.get()) .setParallelism(parallelism)); // u, deg(u), triangle count return vertexDegree .leftOuterJoin(vertexTriangleCount) .where(0) .equalTo(0) .with(new JoinVertexDegreeWithTriangleCount<>()) .setParallelism(parallelism) .name("Clustering coefficient"); }
Example #8
Source File: LocalClusteringCoefficientTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testRMatGraph() throws Exception { DataSet<Result<LongValue>> cc = undirectedRMatGraph(10, 16) .run(new LocalClusteringCoefficient<>()); Checksum checksum = new ChecksumHashCode<Result<LongValue>>() .run(cc) .execute(); assertEquals(902, checksum.getCount()); assertEquals(0x000001cab2d3677bL, checksum.getChecksum()); }
Example #9
Source File: LocalClusteringCoefficientTest.java From flink with Apache License 2.0 | 5 votes |
/** * Validate a test where each result has the same values. * * @param graph input graph * @param count number of results * @param degree result degree * @param triangleCount result triangle count * @param <T> graph ID type * @throws Exception on error */ private static <T extends Comparable<T> & CopyableValue<T>> void validate( Graph<T, NullValue, NullValue> graph, long count, long degree, long triangleCount) throws Exception { DataSet<Result<T>> cc = graph .run(new LocalClusteringCoefficient<>()); List<Result<T>> results = cc.collect(); assertEquals(count, results.size()); for (Result<T> result : results) { assertEquals(degree, result.getDegree().getValue()); assertEquals(triangleCount, result.getTriangleCount().getValue()); } }
Example #10
Source File: LocalClusteringCoefficient.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input) throws Exception { // u, v, w DataSet<TriangleListing.Result<K>> triangles = input .run(new TriangleListing<K, VV, EV>() .setParallelism(parallelism)); // u, 1 DataSet<Tuple2<K, LongValue>> triangleVertices = triangles .flatMap(new SplitTriangles<>()) .name("Split triangle vertices"); // u, triangle count DataSet<Tuple2<K, LongValue>> vertexTriangleCount = triangleVertices .groupBy(0) .reduce(new CountTriangles<>()) .setCombineHint(CombineHint.HASH) .name("Count triangles") .setParallelism(parallelism); // u, deg(u) DataSet<Vertex<K, LongValue>> vertexDegree = input .run(new VertexDegree<K, VV, EV>() .setIncludeZeroDegreeVertices(includeZeroDegreeVertices.get()) .setParallelism(parallelism)); // u, deg(u), triangle count return vertexDegree .leftOuterJoin(vertexTriangleCount) .where(0) .equalTo(0) .with(new JoinVertexDegreeWithTriangleCount<>()) .setParallelism(parallelism) .name("Clustering coefficient"); }
Example #11
Source File: LocalClusteringCoefficient.java From flink with Apache License 2.0 | 5 votes |
@Override public Result<T> join(Vertex<T, LongValue> vertexAndDegree, Tuple2<T, LongValue> vertexAndTriangleCount) throws Exception { output.setVertexId0(vertexAndDegree.f0); output.setDegree(vertexAndDegree.f1); output.setTriangleCount((vertexAndTriangleCount == null) ? zero : vertexAndTriangleCount.f1); return output; }
Example #12
Source File: LocalClusteringCoefficient.java From flink with Apache License 2.0 | 5 votes |
@Override public void flatMap(TriangleListing.Result<T> value, Collector<Tuple2<T, LongValue>> out) throws Exception { output.f0 = value.getVertexId0(); out.collect(output); output.f0 = value.getVertexId1(); out.collect(output); output.f0 = value.getVertexId2(); out.collect(output); }
Example #13
Source File: LocalClusteringCoefficient.java From flink with Apache License 2.0 | 5 votes |
@Override public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input) throws Exception { // u, v, w DataSet<TriangleListing.Result<K>> triangles = input .run(new TriangleListing<K, VV, EV>() .setParallelism(parallelism)); // u, 1 DataSet<Tuple2<K, LongValue>> triangleVertices = triangles .flatMap(new SplitTriangles<>()) .name("Split triangle vertices"); // u, triangle count DataSet<Tuple2<K, LongValue>> vertexTriangleCount = triangleVertices .groupBy(0) .reduce(new CountTriangles<>()) .setCombineHint(CombineHint.HASH) .name("Count triangles") .setParallelism(parallelism); // u, deg(u) DataSet<Vertex<K, LongValue>> vertexDegree = input .run(new VertexDegree<K, VV, EV>() .setIncludeZeroDegreeVertices(includeZeroDegreeVertices.get()) .setParallelism(parallelism)); // u, deg(u), triangle count return vertexDegree .leftOuterJoin(vertexTriangleCount) .where(0) .equalTo(0) .with(new JoinVertexDegreeWithTriangleCount<>()) .setParallelism(parallelism) .name("Clustering coefficient"); }
Example #14
Source File: LocalClusteringCoefficientTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testRMatGraph() throws Exception { DataSet<Result<LongValue>> cc = undirectedRMatGraph(10, 16) .run(new LocalClusteringCoefficient<>()); Checksum checksum = new ChecksumHashCode<Result<LongValue>>() .run(cc) .execute(); assertEquals(902, checksum.getCount()); assertEquals(0x000001cab2d3677bL, checksum.getChecksum()); }
Example #15
Source File: LocalClusteringCoefficientTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Validate a test where each result has the same values. * * @param graph input graph * @param count number of results * @param degree result degree * @param triangleCount result triangle count * @param <T> graph ID type * @throws Exception on error */ private static <T extends Comparable<T> & CopyableValue<T>> void validate( Graph<T, NullValue, NullValue> graph, long count, long degree, long triangleCount) throws Exception { DataSet<Result<T>> cc = graph .run(new LocalClusteringCoefficient<>()); List<Result<T>> results = cc.collect(); assertEquals(count, results.size()); for (Result<T> result : results) { assertEquals(degree, result.getDegree().getValue()); assertEquals(triangleCount, result.getTriangleCount().getValue()); } }
Example #16
Source File: LocalClusteringCoefficientTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testSimpleGraph() throws Exception { String expectedResult = "(0,2,1)\n" + "(1,3,2)\n" + "(2,3,2)\n" + "(3,4,1)\n" + "(4,1,0)\n" + "(5,1,0)"; DataSet<Result<IntValue>> cc = undirectedSimpleGraph .run(new LocalClusteringCoefficient<>()); TestBaseUtils.compareResultAsText(cc.collect(), expectedResult); }
Example #17
Source File: LocalClusteringCoefficient.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public Result<T> join(Vertex<T, LongValue> vertexAndDegree, Tuple2<T, LongValue> vertexAndTriangleCount) throws Exception { output.setVertexId0(vertexAndDegree.f0); output.setDegree(vertexAndDegree.f1); output.setTriangleCount((vertexAndTriangleCount == null) ? zero : vertexAndTriangleCount.f1); return output; }
Example #18
Source File: LocalClusteringCoefficient.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Override public void flatMap(TriangleListing.Result<T> value, Collector<Tuple2<T, LongValue>> out) throws Exception { output.f0 = value.getVertexId0(); out.collect(output); output.f0 = value.getVertexId1(); out.collect(output); output.f0 = value.getVertexId2(); out.collect(output); }