O'Reilly logo

Apache Spark Graph Processing by Rindra Ramamonjison

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modifying graph structures

The GraphX library also comes with four useful methods for changing the structure of graphs. Their method signatures are listed as follows:

class Graph[VD, ED] {
  def reverse: Graph[VD, ED]
  
  def subgraph(epred: EdgeTriplet[VD,ED] => Boolean,
               vpred: (VertexId, VD) => Boolean): Graph[VD, ED]
               
  def mask[VD2, ED2](other: Graph[VD2, ED2]): Graph[VD, ED]
  
  def groupEdges(merge: (ED, ED) => ED): Graph[VD,ED]
}

The reverse operator

As its name suggests, the reverse operator returns a new graph with all the edge directions reversed. It does not modify any vertex or edge properties, or change the number of edges. Moreover, its implementation does not produce any data movement or duplication.

The subgraph operator

Next on the list is subgraph ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required