imen
imen

Reputation: 35

get vertexId graphx

I am new in spark-graphx and scala. How I could get the id of a vertex in graphx?

This my code:

val sourceVertex=graph.vertices.filter { case (id,(_,_,_,_,_)) => id == 0} // The source vertex
var c=sourceVertex.id

I noticed that c is not the id of sourceVertex(c=21 and not 0)

Any ideas? Many thanks

Upvotes: 1

Views: 594

Answers (1)

cheseaux
cheseaux

Reputation: 5315

The ID you're getting, is not the VertexID but the id() function of RDD

A unique ID for this RDD (within its SparkContext).

Since you're expecting to find only one vertex, you can do it using first like this :

val sourceVertex=graph.vertices.filter { case (id,(_,_,_,_,_)) => id == 0}.first
val c=sourceVertex._1

Upvotes: 2

Related Questions