EdgeTriplet Class

An edge triplet represents an edge along with the vertex attributes of its neighboring vertices.
VD: the type of the vertex attribute.
ED: the type of the edge attribute
instance constructor:
new EdgeTriplet()
var attr: ED
The attribute associated with the edge
var dstAttr: VD
The destination vertex attribute
var dstId: VertexId
The vertex id of the target vertex
def otherVertexAttr(vid: VertexId): VD
Given one vertex in the edge return the other vertex.
def otherVertexId(vid: VertexId): VertexId
Given one vertex in the edge return the other vertex.
def relativeDirection(vid: VertexId): EdgeDirection
Return the relative direction of the edge to the corresponding vertex.
var srcAttr: VD
The source vertex attribute
var srcId: VertexId
The vertex id of the source vertex
def toString(): String
toTuple: ((VertexId, VD), (VertexId, VD), ED)
def vertexAttr(vid: VertexId): VD
Get the vertex object for the given vertex in the edge
import org.apache.spark._
import org.apache.spark.graphx._
import org.apache.spark.rdd.RDD
// Create an RDD for the vertices
val users: RDD[(VertexId, (String, String))] =
sc.parallelize(Array((3L, ("rxin", "student")), (7L, ("jgonzal", "postdoc")),
(5L, ("franklin", "prof")), (2L, ("istoica", "prof")),
(4L, ("peter", "student"))))
// Create an RDD for edges
val relationships: RDD[Edge[String]] =
sc.parallelize(Array(Edge(3L, 7L, "collab"), Edge(5L, 3L, "advisor"),
Edge(2L, 5L, "colleague"), Edge(5L, 7L, "pi"),
Edge(4L, 0L, "student"), Edge(5L, 0L, "colleague")))
// Define a default user in case there are relationship with missing user
val defaultUser = ("John Doe", "Missing")
res233: Class[_ <: org.apache.spark.rdd.RDD[org.apache.spark.graphx.EdgeTriplet[(String, String),String]]] = class org.apache.spark.rdd.MapPartitionsRDD
graph.triplets is an instance of EdgeTriplet
// Build the initial Graph
val facts: RDD[String] =
graph.triplets.map((triplet =>
triplet.srcAttr._1 + " is the " + triplet.attr + " of " + triplet.dstAttr._1))