flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gábor Gévay <gga...@gmail.com>
Subject Re: Beginner question - sum multiple edges
Date Mon, 17 Apr 2017 18:32:17 GMT
Hello Marc,

You can group by edge, and then sum:

edges
  .groupBy(0,1) // make first two fields a composite key
  .sum(2); // sum the value field

This will turn multiple edges that have the same source and target
into one edge, whose value will be the sum of the values of the
original group of edges.

Best,
Gabor

PS.: Sorry for the duplicate email, I accidentally sent my previous
email only to you instead of the mailing list.




On Mon, Apr 17, 2017 at 5:46 PM, Kaepke, Marc
<marc.kaepke@haw-hamburg.de> wrote:
> Hi,
>
> how can I sum and reduce multiple edges in my entire graph?
>
> e.g. my input graph looks like (source-ID, target-ID, value):
> (1, 2, 30)
> (1, 2, 10)
> (2, 1, 55)
>
> And I need:
> (1, 2, 40)
> (2, 1, 55)
>
>
> Thanks!
> Marc

Mime
View raw message