(+user)

On Tue, Aug 19, 2014 at 12:05 PM, spr <s...@yarcdata.com> wrote:

> I want to assign each vertex to a community with the name of the vertex.


As I understand it, you want to set the vertex attributes of a graph to the
corresponding vertex ids. You can do this using Graph#mapVertices [1] as
follows:

    val g = ...
    val newG = g.mapVertices((id, attr) => id)
    // newG.vertices has type VertexRDD[VertexId], or RDD[(VertexId,
VertexId)]

If you only want to do this for a VertexRDD without constructing a new
graph using the modified vertices, you can use VertexRDD#mapVertices [2] in
a similar fashion.

[1]
http://spark.apache.org/docs/latest/api/scala/index.html#org.apache.spark.graphx.Graph@mapVertices[VD2]((VertexId,VD)
⇒VD2)(ClassTag[VD2]):Graph[VD2,ED]
[2]
http://spark.apache.org/docs/latest/api/scala/index.html#org.apache.spark.graphx.VertexRDD@mapValues[VD2]((VertexId,VD)
⇒VD2)(ClassTag[VD2]):VertexRDD[VD2]

Ankur <http://www.ankurdave.com/>

Reply via email to