讓我們說我有一個邊緣屬性爲double值的圖形,我想找到我的圖形的最大邊緣權重。如果我這樣做: val max = sc.accumulator(0.0) //max holds the maximum edge weight
g.edges.distinct.collect.foreach{ e => if (e.attr > max.value) max.value
= e.attr }
val degrees: VertexRDD[Int] = graph.degrees
val ngb=graph.collectNeighbors(EdgeDirection.Out)
val deg2 = degrees.leftOuterJoin(ngb)
現在我想要一個鍵/值對RDD,其中鍵是度數,值是鄰居頂點ID。基本上我想從(id,數組[1,2,3])改變爲{(id,1)(id