0

In Scala, I have a an array of VertexIds

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

that i want to convert to a map where

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

What is the most efficient way of doing this?

Eoin Lane
  • 641
  • 2
  • 6
  • 22

1 Answers1

1
v.zipWithIndex.toMap

won't be sorted though

Gavin
  • 6,180
  • 3
  • 25
  • 25