org.apache.flink.graph.asm.degree.annotate.directed.VertexDegrees Java Examples
The following examples show how to use
org.apache.flink.graph.asm.degree.annotate.directed.VertexDegrees.
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: TriadicCensus.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override
public TriadicCensus<K, VV, EV> run(Graph<K, VV, EV> input)
throws Exception {
super.run(input);
triangleListingHelper = new TriangleListingHelper<>();
input
.run(new TriangleListing<K, VV, EV>()
.setParallelism(parallelism))
.output(triangleListingHelper)
.name("Triangle counts");
vertexDegreesHelper = new VertexDegreesHelper<>();
input
.run(new VertexDegrees<K, VV, EV>()
.setParallelism(parallelism))
.output(vertexDegreesHelper)
.name("Edge and triplet counts");
return this;
}
Example #2
Source File: VertexMetrics.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Override
public VertexMetrics<K, VV, EV> run(Graph<K, VV, EV> input)
throws Exception {
super.run(input);
DataSet<Vertex<K, Degrees>> vertexDegree = input
.run(new VertexDegrees<K, VV, EV>()
.setIncludeZeroDegreeVertices(includeZeroDegreeVertices)
.setParallelism(parallelism));
vertexMetricsHelper = new VertexMetricsHelper<>();
vertexDegree
.output(vertexMetricsHelper)
.name("Vertex metrics");
return this;
}
Example #3
Source File: TriadicCensus.java From flink with Apache License 2.0 | 6 votes |
@Override
public TriadicCensus<K, VV, EV> run(Graph<K, VV, EV> input)
throws Exception {
super.run(input);
triangleListingHelper = new TriangleListingHelper<>();
input
.run(new TriangleListing<K, VV, EV>()
.setParallelism(parallelism))
.output(triangleListingHelper)
.name("Triangle counts");
vertexDegreesHelper = new VertexDegreesHelper<>();
input
.run(new VertexDegrees<K, VV, EV>()
.setParallelism(parallelism))
.output(vertexDegreesHelper)
.name("Edge and triplet counts");
return this;
}
Example #4
Source File: VertexMetrics.java From flink with Apache License 2.0 | 6 votes |
@Override
public VertexMetrics<K, VV, EV> run(Graph<K, VV, EV> input)
throws Exception {
super.run(input);
DataSet<Vertex<K, Degrees>> vertexDegree = input
.run(new VertexDegrees<K, VV, EV>()
.setIncludeZeroDegreeVertices(includeZeroDegreeVertices)
.setParallelism(parallelism));
vertexMetricsHelper = new VertexMetricsHelper<>();
vertexDegree
.output(vertexMetricsHelper)
.name("Vertex metrics");
return this;
}
Example #5
Source File: TriadicCensus.java From flink with Apache License 2.0 | 6 votes |
@Override
public TriadicCensus<K, VV, EV> run(Graph<K, VV, EV> input)
throws Exception {
super.run(input);
triangleListingHelper = new TriangleListingHelper<>();
input
.run(new TriangleListing<K, VV, EV>()
.setParallelism(parallelism))
.output(triangleListingHelper)
.name("Triangle counts");
vertexDegreesHelper = new VertexDegreesHelper<>();
input
.run(new VertexDegrees<K, VV, EV>()
.setParallelism(parallelism))
.output(vertexDegreesHelper)
.name("Edge and triplet counts");
return this;
}
Example #6
Source File: VertexMetrics.java From flink with Apache License 2.0 | 6 votes |
@Override
public VertexMetrics<K, VV, EV> run(Graph<K, VV, EV> input)
throws Exception {
super.run(input);
DataSet<Vertex<K, Degrees>> vertexDegree = input
.run(new VertexDegrees<K, VV, EV>()
.setIncludeZeroDegreeVertices(includeZeroDegreeVertices)
.setParallelism(parallelism));
vertexMetricsHelper = new VertexMetricsHelper<>();
vertexDegree
.output(vertexMetricsHelper)
.name("Vertex metrics");
return this;
}
Example #7
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, bitmask
DataSet<TriangleListing.Result<K>> triangles = input
.run(new TriangleListing<K, VV, EV>()
.setParallelism(parallelism));
// u, edge count
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, Degrees>> vertexDegree = input
.run(new VertexDegrees<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: 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, bitmask
DataSet<TriangleListing.Result<K>> triangles = input
.run(new TriangleListing<K, VV, EV>()
.setParallelism(parallelism));
// u, edge count
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, Degrees>> vertexDegree = input
.run(new VertexDegrees<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 #9
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, bitmask
DataSet<TriangleListing.Result<K>> triangles = input
.run(new TriangleListing<K, VV, EV>()
.setParallelism(parallelism));
// u, edge count
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, Degrees>> vertexDegree = input
.run(new VertexDegrees<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 #10
Source File: PageRank.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Override
public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
throws Exception {
// vertex degree
DataSet<Vertex<K, Degrees>> vertexDegree = input
.run(new VertexDegrees<K, VV, EV>()
.setIncludeZeroDegreeVertices(includeZeroDegreeVertices)
.setParallelism(parallelism));
// vertex count
DataSet<LongValue> vertexCount = GraphUtils.count(vertexDegree);
// s, t, d(s)
DataSet<Edge<K, LongValue>> edgeSourceDegree = input
.run(new EdgeSourceDegrees<K, VV, EV>()
.setParallelism(parallelism))
.map(new ExtractSourceDegree<>())
.setParallelism(parallelism)
.name("Extract source degree");
// vertices with zero in-edges
DataSet<Tuple2<K, DoubleValue>> sourceVertices = vertexDegree
.flatMap(new InitializeSourceVertices<>())
.setParallelism(parallelism)
.name("Initialize source vertex scores");
// s, initial pagerank(s)
DataSet<Tuple2<K, DoubleValue>> initialScores = vertexDegree
.map(new InitializeVertexScores<>())
.withBroadcastSet(vertexCount, VERTEX_COUNT)
.setParallelism(parallelism)
.name("Initialize scores");
IterativeDataSet<Tuple2<K, DoubleValue>> iterative = initialScores
.iterate(maxIterations)
.setParallelism(parallelism);
// s, projected pagerank(s)
DataSet<Tuple2<K, DoubleValue>> vertexScores = iterative
.coGroup(edgeSourceDegree)
.where(0)
.equalTo(0)
.with(new SendScore<>())
.setParallelism(parallelism)
.name("Send score")
.groupBy(0)
.reduce(new SumScore<>())
.setCombineHint(CombineHint.HASH)
.setParallelism(parallelism)
.name("Sum");
// ignored ID, total pagerank
DataSet<Tuple2<K, DoubleValue>> sumOfScores = vertexScores
.reduce(new SumVertexScores<>())
.setParallelism(parallelism)
.name("Sum");
// s, adjusted pagerank(s)
DataSet<Tuple2<K, DoubleValue>> adjustedScores = vertexScores
.union(sourceVertices)
.name("Union with source vertices")
.map(new AdjustScores<>(dampingFactor))
.withBroadcastSet(sumOfScores, SUM_OF_SCORES)
.withBroadcastSet(vertexCount, VERTEX_COUNT)
.setParallelism(parallelism)
.name("Adjust scores");
DataSet<Tuple2<K, DoubleValue>> passThrough;
if (convergenceThreshold < Double.MAX_VALUE) {
passThrough = iterative
.join(adjustedScores)
.where(0)
.equalTo(0)
.with(new ChangeInScores<>())
.setParallelism(parallelism)
.name("Change in scores");
iterative.registerAggregationConvergenceCriterion(CHANGE_IN_SCORES, new DoubleSumAggregator(), new ScoreConvergence(convergenceThreshold));
} else {
passThrough = adjustedScores;
}
return iterative
.closeWith(passThrough)
.map(new TranslateResult<>())
.setParallelism(parallelism)
.name("Map result");
}
Example #11
Source File: PageRank.java From flink with Apache License 2.0 | 4 votes |
@Override
public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
throws Exception {
// vertex degree
DataSet<Vertex<K, Degrees>> vertexDegree = input
.run(new VertexDegrees<K, VV, EV>()
.setIncludeZeroDegreeVertices(includeZeroDegreeVertices)
.setParallelism(parallelism));
// vertex count
DataSet<LongValue> vertexCount = GraphUtils.count(vertexDegree);
// s, t, d(s)
DataSet<Edge<K, LongValue>> edgeSourceDegree = input
.run(new EdgeSourceDegrees<K, VV, EV>()
.setParallelism(parallelism))
.map(new ExtractSourceDegree<>())
.setParallelism(parallelism)
.name("Extract source degree");
// vertices with zero in-edges
DataSet<Tuple2<K, DoubleValue>> sourceVertices = vertexDegree
.flatMap(new InitializeSourceVertices<>())
.setParallelism(parallelism)
.name("Initialize source vertex scores");
// s, initial pagerank(s)
DataSet<Tuple2<K, DoubleValue>> initialScores = vertexDegree
.map(new InitializeVertexScores<>())
.withBroadcastSet(vertexCount, VERTEX_COUNT)
.setParallelism(parallelism)
.name("Initialize scores");
IterativeDataSet<Tuple2<K, DoubleValue>> iterative = initialScores
.iterate(maxIterations)
.setParallelism(parallelism);
// s, projected pagerank(s)
DataSet<Tuple2<K, DoubleValue>> vertexScores = iterative
.coGroup(edgeSourceDegree)
.where(0)
.equalTo(0)
.with(new SendScore<>())
.setParallelism(parallelism)
.name("Send score")
.groupBy(0)
.reduce(new SumScore<>())
.setCombineHint(CombineHint.HASH)
.setParallelism(parallelism)
.name("Sum");
// ignored ID, total pagerank
DataSet<Tuple2<K, DoubleValue>> sumOfScores = vertexScores
.reduce(new SumVertexScores<>())
.setParallelism(parallelism)
.name("Sum");
// s, adjusted pagerank(s)
DataSet<Tuple2<K, DoubleValue>> adjustedScores = vertexScores
.union(sourceVertices)
.name("Union with source vertices")
.map(new AdjustScores<>(dampingFactor))
.withBroadcastSet(sumOfScores, SUM_OF_SCORES)
.withBroadcastSet(vertexCount, VERTEX_COUNT)
.setParallelism(parallelism)
.name("Adjust scores");
DataSet<Tuple2<K, DoubleValue>> passThrough;
if (convergenceThreshold < Double.MAX_VALUE) {
passThrough = iterative
.join(adjustedScores)
.where(0)
.equalTo(0)
.with(new ChangeInScores<>())
.setParallelism(parallelism)
.name("Change in scores");
iterative.registerAggregationConvergenceCriterion(CHANGE_IN_SCORES, new DoubleSumAggregator(), new ScoreConvergence(convergenceThreshold));
} else {
passThrough = adjustedScores;
}
return iterative
.closeWith(passThrough)
.map(new TranslateResult<>())
.setParallelism(parallelism)
.name("Map result");
}
Example #12
Source File: PageRank.java From flink with Apache License 2.0 | 4 votes |
@Override
public DataSet<Result<K>> runInternal(Graph<K, VV, EV> input)
throws Exception {
// vertex degree
DataSet<Vertex<K, Degrees>> vertexDegree = input
.run(new VertexDegrees<K, VV, EV>()
.setIncludeZeroDegreeVertices(includeZeroDegreeVertices)
.setParallelism(parallelism));
// vertex count
DataSet<LongValue> vertexCount = GraphUtils.count(vertexDegree);
// s, t, d(s)
DataSet<Edge<K, LongValue>> edgeSourceDegree = input
.run(new EdgeSourceDegrees<K, VV, EV>()
.setParallelism(parallelism))
.map(new ExtractSourceDegree<>())
.setParallelism(parallelism)
.name("Extract source degree");
// vertices with zero in-edges
DataSet<Tuple2<K, DoubleValue>> sourceVertices = vertexDegree
.flatMap(new InitializeSourceVertices<>())
.setParallelism(parallelism)
.name("Initialize source vertex scores");
// s, initial pagerank(s)
DataSet<Tuple2<K, DoubleValue>> initialScores = vertexDegree
.map(new InitializeVertexScores<>())
.withBroadcastSet(vertexCount, VERTEX_COUNT)
.setParallelism(parallelism)
.name("Initialize scores");
IterativeDataSet<Tuple2<K, DoubleValue>> iterative = initialScores
.iterate(maxIterations)
.setParallelism(parallelism);
// s, projected pagerank(s)
DataSet<Tuple2<K, DoubleValue>> vertexScores = iterative
.coGroup(edgeSourceDegree)
.where(0)
.equalTo(0)
.with(new SendScore<>())
.setParallelism(parallelism)
.name("Send score")
.groupBy(0)
.reduce(new SumScore<>())
.setCombineHint(CombineHint.HASH)
.setParallelism(parallelism)
.name("Sum");
// ignored ID, total pagerank
DataSet<Tuple2<K, DoubleValue>> sumOfScores = vertexScores
.reduce(new SumVertexScores<>())
.setParallelism(parallelism)
.name("Sum");
// s, adjusted pagerank(s)
DataSet<Tuple2<K, DoubleValue>> adjustedScores = vertexScores
.union(sourceVertices)
.name("Union with source vertices")
.map(new AdjustScores<>(dampingFactor))
.withBroadcastSet(sumOfScores, SUM_OF_SCORES)
.withBroadcastSet(vertexCount, VERTEX_COUNT)
.setParallelism(parallelism)
.name("Adjust scores");
DataSet<Tuple2<K, DoubleValue>> passThrough;
if (convergenceThreshold < Double.MAX_VALUE) {
passThrough = iterative
.join(adjustedScores)
.where(0)
.equalTo(0)
.with(new ChangeInScores<>())
.setParallelism(parallelism)
.name("Change in scores");
iterative.registerAggregationConvergenceCriterion(CHANGE_IN_SCORES, new DoubleSumAggregator(), new ScoreConvergence(convergenceThreshold));
} else {
passThrough = adjustedScores;
}
return iterative
.closeWith(passThrough)
.map(new TranslateResult<>())
.setParallelism(parallelism)
.name("Map result");
}