Hi Gábor and anyone else ;-) ,

I need your help again.

My goal is a graph without self-loops and sum all edge values between two 
vertices into one single edge (both direction).
e.g. my input graph is described by:
1 2 10
1 2 10
2 1 10
1 1 1
1 3 5

The result has to be:
1 2 30 (sum and reduce all edges between vertex 1 and 2. I don’t care about the 
direction of these vertices because of the setDirection(EdgeDirection.ALL) 
parameter)
1 3 5


My intermediate result is:
1 2 20
2 1 10
1 3 5
with the following transformations:


ScatterGatherConfiguration parameters = new ScatterGatherConfiguration();
parameters.setDirection(EdgeDirection.ALL);

// reduce multi edges
Graph networkSumMultiEdges = 
Graph.fromTupleDataSet(inputGraph.getEdges().groupBy(0, 1).sum(2), 
ExecutionEnvironment.getExecutionEnvironment());
// reduce self-looping
Graph networkGraph = new Simplify<>().run(networkSumMultiEdges);

How can I reduce and combine (1 2 20) and (2 1 10) to one Tuple?


Best regards
Marc


Am 17.04.2017 um 21:47 schrieb Kaepke, Marc 
<[email protected]<mailto:[email protected]>>:

Hi Gábor,

thanks a lot

Best,
Marc

Am 17.04.2017 um 20:32 schrieb Gábor Gévay 
<[email protected]<mailto:[email protected]>>:

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
<[email protected]<mailto:[email protected]>> 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


Reply via email to