Arrays GraphX-如何将数组[(顶点ID,数组(顶点ID)]转换为集合(顶点ID)

Arrays GraphX-如何将数组[(顶点ID,数组(顶点ID)]转换为集合(顶点ID),arrays,scala,graph,set,Arrays,Scala,Graph,Set,给定该顶点ID,我通过使用以下代码执行collectNeighborsId和查找,获得所有直接连接到该顶点的顶点(即,只有一条边距离): val ID = 20 val res = graph.collectNeighborIds(EdgeDirection.Out).lookup(ID) 生成的类是ArrayBuffer(数组(长),如下所示: ArrayBuffer(Array(10006, 10009, 10015, 10017, 10025, 10028, 10030, 10037,

给定该顶点ID,我通过使用以下代码执行collectNeighborsId和查找,获得所有直接连接到该顶点的顶点(即,只有一条边距离):

val ID = 20
val res = graph.collectNeighborIds(EdgeDirection.Out).lookup(ID)
生成的类是ArrayBuffer(数组(长),如下所示:

ArrayBuffer(Array(10006, 10009, 10015, 10017, 10025, 10028, 10030, 10037, 10041, 10043, 10046, 10049, 10055, 10056, 10057, 10058, 10059, 10060, 10061, 10068, 10070, 10081, 10082, 10087, 10096, 10101, 10105, 10108, 10111, 10113, 10115, 10119, 10125, 10127, 10129, 10132, 10136, 10137, 10141, 10150, 10152, 10153, 10156, 10158, 10163, 10166, 10167, 10171, 10172, 10173, 10175, 10183, 10186, 10187, 10192, 10193, 10197, 10198, 10201, 10209, 10212, 10213, 10214, 10223, 10226, 10228, 1367, 1654, 1670, 2034, 2146, 2481, 58776, 58778, 58788, 58789))
我需要把它转换成一个集合[长]。。 我试着用toSet.转换它,但结果仍然是数组(Set[Long])

使用:


您使用的是哪个版本的GraphX?根据[API文档](CollectNeighborrids),
CollectNeighborrids
返回一个
VertexRDD
,它似乎没有方法
查找
。。。
scala> val a: Array[Array[Long]] = Array(Array(1, 2), Array(3, 4))
a: Array[Array[Long]] = Array(Array(1, 2), Array(3, 4))

scala> a.flatten.toSet
res1: scala.collection.immutable.Set[Long] = Set(1, 2, 3, 4)