The map operator is a core method for transforming distributed datasets or RDDs in Spark. Similarly, property graphs also have three map operators defined as follows:
class Graph[VD, ED] { def mapVertices[VD2](mapFun: (VertexId, VD) => VD2): Graph[VD2, ED] def mapEdges[ED2](mapFun: Edge[ED] => ED2): Graph[VD, ED2] def mapTriplets[ED2](mapFun: EdgeTriplet[VD, ED] => ED2): Graph[VD, ED2] }
Each of these methods is called on a property graph with vertex attribute type VD
and edge attribute type ED
. Each of them also takes a user-defined mapping function mapFun
that performs one of the following:
For
mapVertices
,mapFun
takes a pair of(VertexId, VD)
as input and returns a transformed vertex attribute of typeVD2
.For
mapEdges
,mapFun
takes anEdge
object as input and returns a transformed edge attribute of typeED2
.For
mapTriplets
,mapFun
takes anEdgeTriplet
object as input and returns a transformed edge attribute of typeED2
.