2016-07-07 87 views
0

在Scala中,我有一個VertexIds如何將Scala中的數組[VertexIds]轉換爲Map?

v: Array[org.apache.spark.graphx.VertexId] = Array(-2634311911308936962, 2326575714372975825, ...) 

的數組,我想轉換成地圖,

Map(-2634311911308936962 -> 0, 
    2326575714372975825 -> 1, 
    ... 
) 

什麼是這樣做的最有效的方法是什麼?

+0

v.zipWithIndex.toMap些功夫 – mavarazy

回答

1
v.zipWithIndex.toMap 

將不能進行排序儘管

+0

完美加文,感謝您的幫助。 –

相關問題