[
https://issues.apache.org/jira/browse/FLINK-1758?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14499844#comment-14499844
]
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_r28594425
--- Diff: docs/gelly_guide.md ---
@@ -282,25 +290,28 @@ The following code will collect the out-edges for
each vertex and apply the `Sel
{% highlight java %}
Graph<Long, Long, Double> graph = ...
-DataSet<Tuple2<Long, Double>> minWeights = graph.reduceOnEdges(
+DataSet<Tuple2<Long, Double>> minWeights = graph.groupReduceOnEdges(
new SelectMinWeight(), EdgeDirection.OUT);
// user-defined function to select the minimum weight
-static final class SelectMinWeight implements EdgesFunction<Long, Double,
Tuple2<Long, Double>> {
+static final class SelectMinWeightNeighbor implements
EdgesFunctionWithVertexValue<Long, Long, Long, Tuple2<Long, Long>> {
- public Tuple2<Long, Double> iterateEdges(Iterable<Tuple2<Long,
Edge<Long, Double>>> edges) {
+ @Override
+ public void iterateEdges(Vertex<Long, Long> v,
+ Iterable<Edge<Long, Long>> edges,
Collector<Tuple2<Long, Long>> out) throws Exception {
- long minWeight = Double.MAX_VALUE;
- long vertexId = -1;
+ long weight = Long.MAX_VALUE;
+ long minNeighborId = 0;
- for (Tuple2<Long, Edge<Long, Double>> edge: edges) {
- if (edge.f1.getValue() < weight) {
- weight = edge.f1.getValue();
- vertexId = edge.f0;
- }
- return new Tuple2<Long, Double>(vertexId, minWeight);
- }
-}
+ for (Edge<Long, Long> edge: edges) {
+ if (edge.getValue() < weight) {
+ weight = edge.getValue();
+ minNeighborId = edge.getTarget();
+ }
+ }
+ out.collect(new Tuple2<Long, Long>(v.getId(),
minNeighborId));
+ }
+ }
--- End diff --
Also, the description says `SelectMinWeight` but the method name is
`SelectMinWeightNeighbor`.
> 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)