Reputation: 3015
I've looked around the internet at examples of the field inDegrees for graphs in GraphX and they've all said that it returns indegrees for every vertex in the graph. However when I do the following example:
val a = sc.parallelize(List(Edge(1L, 2L, 3L)))
val g = Graph.fromEdges[Long, Long](a, 0)
g.numVertices
g.inDegrees.take(5).foreach(println)
I get 2 vertices but only 1 indegree pair is returned. This seems like a strange implementation. Am I doing something wrong?
Upvotes: 0
Views: 1013
Reputation: 1639
Yes, inDegrees doesn't return vertices with zero indegree. Similarly, outDegrees doesn't return vertices with zero outdegree. However, it is usually not a problem, since operations involving RDD[(VertexID, U)]
like joins work with Option
; see example from GraphX guide:
// A graph where the vertex property is the out degree
val inputGraph: Graph[Int, String] =
graph.outerJoinVertices(graph.outDegrees)((vid, _, degOpt) => degOpt.getOrElse(0))
Upvotes: 2