如何在 Scala 中将 Array[VertexIds] 转换为 Map?

How to convert, in Scala, an Array[VertexIds] to a Map?

在 Scala 中,我有一个 VertexId 数组

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

我想转换成地图,其中

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

最有效的方法是什么?

v.zipWithIndex.toMap

虽然不会排序