Github user vasia commented on a diff in the pull request:

    https://github.com/apache/flink/pull/576#discussion_r28594318
  
    --- 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 --
    
    I think it's confusing what this example is doing now. The description says 
that each vertex selects the min weight among its edges, yet you modified it to 
return the ID of the target neighbor of that edge. Do you want to show 
something that I'm missing here? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to