org.apache.flink.graph.asm.dataset.Collect Java Examples
The following examples show how to use
org.apache.flink.graph.asm.dataset.Collect.
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: PageRankTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Result<LongValue>> pr = new PageRank<LongValue, NullValue, NullValue>(DAMPING_FACTOR, ACCURACY) .run(directedRMatGraph(10, 16)); Map<Long, Result<LongValue>> results = new HashMap<>(); for (Result<LongValue> result : new Collect<Result<LongValue>>().run(pr).execute()) { results.put(result.getVertexId0().getValue(), result); } assertEquals(902, results.size()); Map<Long, Double> expectedResults = new HashMap<>(); // a pseudo-random selection of results, both high and low expectedResults.put(0L, 0.0271152394743); expectedResults.put(1L, 0.0132848430616); expectedResults.put(2L, 0.0121819700294); expectedResults.put(8L, 0.0115923214664); expectedResults.put(13L, 0.00183241122822); expectedResults.put(29L, 0.000848190646547); expectedResults.put(109L, 0.00030846825644); expectedResults.put(394L, 0.000828826945546); expectedResults.put(652L, 0.000683948671035); expectedResults.put(1020L, 0.000250442325034); for (Map.Entry<Long, Double> expected : expectedResults.entrySet()) { double value = results.get(expected.getKey()).getPageRankScore().getValue(); assertEquals(expected.getValue(), value, ACCURACY); } }
Example #2
Source File: HITSTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Result<LongValue>> hits = directedRMatGraph(10, 16) .run(new HITS<>(ACCURACY)); Map<Long, Result<LongValue>> results = new HashMap<>(); for (Result<LongValue> result : new Collect<Result<LongValue>>().run(hits).execute()) { results.put(result.getVertexId0().getValue(), result); } assertEquals(902, results.size()); Map<Long, Tuple2<Double, Double>> expectedResults = new HashMap<>(); // a pseudo-random selection of results, both high and low expectedResults.put(0L, Tuple2.of(0.231077034503, 0.238110215657)); expectedResults.put(1L, Tuple2.of(0.162364053853, 0.169679504542)); expectedResults.put(2L, Tuple2.of(0.162412612418, 0.161015667467)); expectedResults.put(8L, Tuple2.of(0.167064641648, 0.158592966732)); expectedResults.put(13L, Tuple2.of(0.0419155956364, 0.0407091624972)); expectedResults.put(29L, Tuple2.of(0.0102017346609, 0.0146218045619)); expectedResults.put(109L, Tuple2.of(0.00190531000308, 0.00481944991974)); expectedResults.put(394L, Tuple2.of(0.0122287016151, 0.0147987969383)); expectedResults.put(652L, Tuple2.of(0.0109666592418, 0.0113713306828)); expectedResults.put(1020L, Tuple2.of(0.0, 0.000326973733252)); for (Map.Entry<Long, Tuple2<Double, Double>> expected : expectedResults.entrySet()) { double hubScore = results.get(expected.getKey()).getHubScore().getValue(); double authorityScore = results.get(expected.getKey()).getAuthorityScore().getValue(); assertEquals(expected.getValue().f0, hubScore, ACCURACY); assertEquals(expected.getValue().f1, authorityScore, ACCURACY); } }
Example #3
Source File: PageRankTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Result<LongValue>> pr = new PageRank<LongValue, NullValue, NullValue>(DAMPING_FACTOR, ACCURACY) .run(directedRMatGraph(10, 16)); Map<Long, Result<LongValue>> results = new HashMap<>(); for (Result<LongValue> result : new Collect<Result<LongValue>>().run(pr).execute()) { results.put(result.getVertexId0().getValue(), result); } assertEquals(902, results.size()); Map<Long, Double> expectedResults = new HashMap<>(); // a pseudo-random selection of results, both high and low expectedResults.put(0L, 0.0271152394743); expectedResults.put(1L, 0.0132848430616); expectedResults.put(2L, 0.0121819700294); expectedResults.put(8L, 0.0115923214664); expectedResults.put(13L, 0.00183241122822); expectedResults.put(29L, 0.000848190646547); expectedResults.put(109L, 0.00030846825644); expectedResults.put(394L, 0.000828826945546); expectedResults.put(652L, 0.000683948671035); expectedResults.put(1020L, 0.000250442325034); for (Map.Entry<Long, Double> expected : expectedResults.entrySet()) { double value = results.get(expected.getKey()).getPageRankScore().getValue(); assertEquals(expected.getValue(), value, ACCURACY); } }
Example #4
Source File: HITSTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Result<LongValue>> hits = directedRMatGraph(10, 16) .run(new HITS<>(ACCURACY)); Map<Long, Result<LongValue>> results = new HashMap<>(); for (Result<LongValue> result : new Collect<Result<LongValue>>().run(hits).execute()) { results.put(result.getVertexId0().getValue(), result); } assertEquals(902, results.size()); Map<Long, Tuple2<Double, Double>> expectedResults = new HashMap<>(); // a pseudo-random selection of results, both high and low expectedResults.put(0L, Tuple2.of(0.231077034503, 0.238110215657)); expectedResults.put(1L, Tuple2.of(0.162364053853, 0.169679504542)); expectedResults.put(2L, Tuple2.of(0.162412612418, 0.161015667467)); expectedResults.put(8L, Tuple2.of(0.167064641648, 0.158592966732)); expectedResults.put(13L, Tuple2.of(0.0419155956364, 0.0407091624972)); expectedResults.put(29L, Tuple2.of(0.0102017346609, 0.0146218045619)); expectedResults.put(109L, Tuple2.of(0.00190531000308, 0.00481944991974)); expectedResults.put(394L, Tuple2.of(0.0122287016151, 0.0147987969383)); expectedResults.put(652L, Tuple2.of(0.0109666592418, 0.0113713306828)); expectedResults.put(1020L, Tuple2.of(0.0, 0.000326973733252)); for (Map.Entry<Long, Tuple2<Double, Double>> expected : expectedResults.entrySet()) { double hubScore = results.get(expected.getKey()).getHubScore().getValue(); double authorityScore = results.get(expected.getKey()).getAuthorityScore().getValue(); assertEquals(expected.getValue().f0, hubScore, ACCURACY); assertEquals(expected.getValue().f1, authorityScore, ACCURACY); } }
Example #5
Source File: PageRankTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Result<LongValue>> pr = new PageRank<LongValue, NullValue, NullValue>(DAMPING_FACTOR, ACCURACY) .run(directedRMatGraph(10, 16)); Map<Long, Result<LongValue>> results = new HashMap<>(); for (Result<LongValue> result : new Collect<Result<LongValue>>().run(pr).execute()) { results.put(result.getVertexId0().getValue(), result); } assertEquals(902, results.size()); Map<Long, Double> expectedResults = new HashMap<>(); // a pseudo-random selection of results, both high and low expectedResults.put(0L, 0.0271152394743); expectedResults.put(1L, 0.0132848430616); expectedResults.put(2L, 0.0121819700294); expectedResults.put(8L, 0.0115923214664); expectedResults.put(13L, 0.00183241122822); expectedResults.put(29L, 0.000848190646547); expectedResults.put(109L, 0.00030846825644); expectedResults.put(394L, 0.000828826945546); expectedResults.put(652L, 0.000683948671035); expectedResults.put(1020L, 0.000250442325034); for (Map.Entry<Long, Double> expected : expectedResults.entrySet()) { double value = results.get(expected.getKey()).getPageRankScore().getValue(); assertEquals(expected.getValue(), value, ACCURACY); } }
Example #6
Source File: HITSTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testWithRMatGraph() throws Exception { DataSet<Result<LongValue>> hits = directedRMatGraph(10, 16) .run(new HITS<>(ACCURACY)); Map<Long, Result<LongValue>> results = new HashMap<>(); for (Result<LongValue> result : new Collect<Result<LongValue>>().run(hits).execute()) { results.put(result.getVertexId0().getValue(), result); } assertEquals(902, results.size()); Map<Long, Tuple2<Double, Double>> expectedResults = new HashMap<>(); // a pseudo-random selection of results, both high and low expectedResults.put(0L, Tuple2.of(0.231077034503, 0.238110215657)); expectedResults.put(1L, Tuple2.of(0.162364053853, 0.169679504542)); expectedResults.put(2L, Tuple2.of(0.162412612418, 0.161015667467)); expectedResults.put(8L, Tuple2.of(0.167064641648, 0.158592966732)); expectedResults.put(13L, Tuple2.of(0.0419155956364, 0.0407091624972)); expectedResults.put(29L, Tuple2.of(0.0102017346609, 0.0146218045619)); expectedResults.put(109L, Tuple2.of(0.00190531000308, 0.00481944991974)); expectedResults.put(394L, Tuple2.of(0.0122287016151, 0.0147987969383)); expectedResults.put(652L, Tuple2.of(0.0109666592418, 0.0113713306828)); expectedResults.put(1020L, Tuple2.of(0.0, 0.000326973733252)); for (Map.Entry<Long, Tuple2<Double, Double>> expected : expectedResults.entrySet()) { double hubScore = results.get(expected.getKey()).getHubScore().getValue(); double authorityScore = results.get(expected.getKey()).getAuthorityScore().getValue(); assertEquals(expected.getValue().f0, hubScore, ACCURACY); assertEquals(expected.getValue().f1, authorityScore, ACCURACY); } }