March 2019
Beginner to intermediate
182 pages
4h 6m
English
The out-degree explains how many vertices are going out. This time, we'll be calculating the sources of our edges, relationships, and not destinations, like we did in the in-degree method.
To get the out-degree, we will use the following code:
val degrees = graph.outDegrees.collect().toList
The outDegrees method contains both RDD and VertexRDD, which we have collected to a list using the collect and toList methods.
Here, VertexId 1L should have two outbound vertices because there is a relationship between 1L, 2L and 1L, 3L:
test("should calculate out-degree of vertices") { //given val users: RDD[(VertexId, (String))] = spark.parallelize(Array( (1L, "a"), (2L, "b"), (3L, "c"), (4L, "d") )) val relationships = spark.parallelize(Array( ...Read now
Unlock full access