EdgeRDD Class
abstract class EdgeRDD[ED] extends RDD[Edge[ED]]
Instance constructor:
new EdgeRDD(sc: SparkContext, deps: Seq[Dependency[_]])
1
abstract def innerJoin[ED2, ED3](other: EdgeRDD[ED2])(f: (VertexId, VertexId, ED, ED2) β‡’ ED3)(implicit arg0: ClassTag[ED2], arg1: ClassTag[ED3]): EdgeRDD[ED3]
2
​
3
Inner joins this EdgeRDD with another EdgeRDD, assuming both are partitioned using the same PartitionStrategy.
4
​
5
abstract def mapValues[ED2](f: (Edge[ED]) β‡’ ED2)(implicit arg0: ClassTag[ED2]): EdgeRDD[ED2]
6
​
7
Map the values in an edge partitioning preserving the structure but changing the values.
8
​
9
abstract def reverse: EdgeRDD[ED]
10
​
11
Reverse all the edges in this RDD
Copied!
Example:
1
import org.apache.spark._
2
import org.apache.spark.graphx._
3
import org.apache.spark.rdd.RDD
4
​
5
// Create an RDD for the vertices
6
val users: RDD[(VertexId, (String, String))] =
7
sc.parallelize(Array((3L, ("rxin", "student")), (7L, ("jgonzal", "postdoc")),
8
(5L, ("franklin", "prof")), (2L, ("istoica", "prof")),
9
(4L, ("peter", "student"))))
10
// Create an RDD for edges
11
val relationships: RDD[Edge[String]] =
12
sc.parallelize(Array(Edge(3L, 7L, "collab"), Edge(5L, 3L, "advisor"),
13
Edge(2L, 5L, "colleague"), Edge(5L, 7L, "pi"),
14
Edge(4L, 0L, "student"), Edge(5L, 0L, "colleague")))
15
// Define a default user in case there are relationship with missing user
16
val defaultUser = ("John Doe", "Missing")
17
​
18
val graph = Graph(users, relationships, defaultUser)
19
​
20
val edges = EdgeRDD.fromEdges(relationships.map(x=>Edge(x.srcId,x.dstId,"EdgeRDD")))
21
edges.take(5).foreach(println)
22
/*
23
Edge(2,5,EdgeRDD)
24
Edge(3,7,EdgeRDD)
25
Edge(5,3,EdgeRDD)
26
Edge(4,0,EdgeRDD)
27
Edge(5,0,EdgeRDD)
28
*/
Copied!
reference:
Last modified 1yr ago
Copy link