The direction of a directed edge relative to a vertex.
def equals(o: Any): Boolean
def hashCode(): Int
def reverse: EdgeDirection
def toString(): String
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")
// Build the initial Graph
val graph = Graph(users, relationships, defaultUser)
graph.collectNeighborIds(EdgeDirection.Either).take(5).foreach(println)
/*
Output:
(4,[J@3bbc878d)
(0,[J@273cd011)
(2,[J@2f5bc77b)
(3,[J@353a0c3d)
(7,[J@6a6575f8)
*/