You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Ranjana Rajendran <ra...@gmail.com> on 2015/08/14 20:04:46 UTC

Fwd: Graphx - how to add vertices to a HashSet of vertices ?

---------- Forwarded message ----------
From: Ranjana Rajendran <ra...@gmail.com>
Date: Thu, Aug 13, 2015 at 7:37 AM
Subject: Graphx - how to add vertices to a HashSet of vertices ?
To: dev@spark.apache.org


Hi,

sampledVertices is a HashSet of vertices

      var sampledVertices: HashSet[VertexId] = HashSet()

In each iteration, I am making a list of neighborVertexIds

      val neighborVertexIds = burnEdges.map((e:Edge[Int]) => e.dstId)

I want to add this neighborVertexIds to the sampledVertices Hashset.

What is the best way to do this ?

   Currently, I have

sampledVertices = sampledVertices ++ neighborVertexIds.toArray

I realize, toArray is making this a separate stage.

What will be the most efficient way to achieve this ?

Similarly, I need to add the neighborVertexIds to burnQueue where burnQueue
is is a queue of vertices

var burnQueue: Queue[VertexId] = Queue()

Thank you,

Ranjana