[ https://issues.apache.org/jira/browse/FLINK-1758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14499846#comment-14499846 ]
ASF GitHub Bot commented on FLINK-1758: --------------------------------------- Github user vasia commented on a diff in the pull request: https://github.com/apache/flink/pull/576#discussion_r28594561 --- Diff: docs/gelly_guide.md --- @@ -316,28 +327,49 @@ DataSet<Tuple2<Long, Long>> verticesWithSum = graph.reduceOnNeighbors( new SumValues(), EdgeDirection.IN); // user-defined function to sum the neighbor values -static final class SumValues implements NeighborsFunction<Long, Long, Double, Tuple2<Long, Long>> { - - public Tuple2<Long, Long> iterateNeighbors(Iterable<Tuple3<Long, Edge<Long, Double>, - Vertex<Long, Long>>> neighbors) { - - long sum = 0; - long vertexId = -1; +static final class SumValues implements ReduceNeighborsFunction<Long, Long, Double> { - for (Tuple3<Long, Edge<Long, Double>, Vertex<Long, Long>> neighbor : neighbors) { - vertexId = neighbor.f0; - sum += neighbor.f2.getValue(); - } - return new Tuple2<Long, Long>(vertexId, sum); - } + public Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> reduceNeighbors(Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> firstNeighbor, + Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> secondNeighbor) { + + long sum = firstNeighbor.f2.getValue() + secondNeighbor.f2.getValue(); + return new Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>(firstNeighbor.f0, firstNeighbor.f1, + new Vertex<Long, Long>(firstNeighbor.f0, sum)); + } } {% endhighlight %} <p class="text-center"> - <img alt="reduseOnNeighbors Example" width="70%" src="img/gelly-reduceOnNeighbors.png"/> + <img alt="reduceOnNeighbors Example" width="70%" src="img/gelly-reduceOnNeighbors.png"/> --- End diff -- good catch :+1: > Extend Gelly's neighborhood methods > ----------------------------------- > > Key: FLINK-1758 > URL: https://issues.apache.org/jira/browse/FLINK-1758 > Project: Flink > Issue Type: Improvement > Components: Gelly > Affects Versions: 0.9 > Reporter: Vasia Kalavri > Assignee: Andra Lungu > > Currently, the neighborhood methods only allow returning a single value per > vertex. In many cases, it is desirable to return several or no value per > vertex. This is the case in clustering coefficient computation, > vertex-centric jaccard, algorithms where a vertex computes a value per edge > or when a vertex computes a value only for some of its neighbors. > This issue proposes to > - change the current reduceOnEdges/reduceOnNeighbors methods to use > combinable reduce operations where possible > - provide groupReduce-versions, which will use a Collector and allow > returning none or more values per vertex. -- This message was sent by Atlassian JIRA (v6.3.4#6332)