Graph Class

abstract class Graph[VD, ED] extends Serializable

The Graph abstractly represents a graph with arbitrary objects associated with vertices and edges. The graph provides basic operations to access and manipulate the data associated with vertices and edges as well as the underlying structure. Like Spark RDDs, the graph is a functional data-structure in which mutating operations return new graphs.

VD the vertex attribute type

ED the edge attribute type

Abstract methods:

abstract def cache(): Graph[VD, ED]
Caches the vertices and edges associated with this graph at the previously-specified target storage levels, which default to MEMORY_ONLY.

abstract def checkpoint(): Unit
Mark this Graph for checkpointing.

abstract val edges: EdgeRDD[ED]
An RDD containing the edges and their associated attributes.

abstract def getCheckpointFiles: Seq[String]
Gets the name of the files to which this Graph was checkpointed.

abstract def groupEdges(merge: (ED, ED) ⇒ ED): Graph[VD, ED]
Merges multiple edges between two vertices into a single edge.

abstract def isCheckpointed: Boolean
Return whether this Graph has been checkpointed or not.

abstract def mapEdges[ED2](map: (PartitionID, Iterator[Edge[ED]]) ⇒ Iterator[ED2])(implicit arg0: ClassTag[ED2]): Graph[VD, ED2]
Transforms each edge attribute using the map function, passing it a whole partition at a time.

abstract def mapTriplets[ED2](map: (PartitionID, Iterator[EdgeTriplet[VD, ED]]) => Iterator[ED2], tripletFields: TripletFields)(implicit arg0: ClassTag[ED2]): Graph[VD, ED2]
Transforms each edge attribute a partition at a time using the map function, passing it the adjacent vertex attributes as well.

abstract def mapVertices[VD2](map: (VertexId, VD) => VD2)(implicit arg0: ClassTag[VD2], eq: =:=[VD, VD2] = null): Graph[VD2, ED]
Transforms each vertex attribute in the graph using the map function.

abstract def mask[VD2, ED2](other: Graph[VD2, ED2])(implicit arg0: ClassTag[VD2], arg1: ClassTag[ED2]): Graph[VD, ED]
Restricts the graph to only the vertices and edges that are also in other, but keeps the attributes from this graph.

abstract def outerJoinVertices[U, VD2](other: RDD[(VertexId, U)])(mapFunc: (VertexId, VD, Option[U]) ⇒ VD2)(implicit arg0: ClassTag[U], arg1: ClassTag[VD2], eq: =:=[VD, VD2] = null): Graph[VD2, ED]
Joins the vertices with entries in the table RDD and merges the results using mapFunc.

abstract def partitionBy(partitionStrategy: PartitionStrategy, numPartitions: Int): Graph[VD, ED]
Repartitions the edges in the graph according to partitionStrategy.

abstract def partitionBy(partitionStrategy: PartitionStrategy): Graph[VD, ED]
Repartitions the edges in the graph according to partitionStrategy.

abstract def persist(newLevel: StorageLevel = StorageLevel.MEMORY_ONLY): Graph[VD, ED]
Caches the vertices and edges associated with this graph at the specified storage level, ignoring any target storage levels previously set.

abstract reverse: def Graph[VD, ED]
Reverses all edges in the graph.

abstract def subgraph(epred: (EdgeTriplet[VD, ED]) ⇒ Boolean = x => true, vpred: (VertexId, VD) ⇒ Boolean = (v, d) => true): Graph[VD, ED]
Restricts the graph to only the vertices and edges satisfying the predicates.

abstract val triplets: RDD[EdgeTriplet[VD, ED]]
An RDD containing the edge triplets, which are edges along with the vertex data associated with the adjacent vertices.

abstract def unpersist(blocking: Boolean = true): Graph[VD, ED]
Uncaches both vertices and edges of this graph.

abstract def unpersistVertices (blocking: Boolean = true): Graph[VD, ED]
Uncaches only the vertices of this graph, leaving the edges alone.

abstract vertices val VertexRDD[VD]
An RDD containing the vertices and their associated attributes

Concrete methods:

def aggregateMessages[A](sendMsg: (EdgeContext[VD, ED, A]) ⇒ Unit, mergeMsg: (A, A) ⇒ A, tripletFields: TripletFields = TripletFields.All)(implicit arg0: ClassTag[A]): VertexRDD[A]

Aggregates values from the neighboring edges and vertices of each vertex.

def mapEdges[ED2](map: (Edge[ED]) ⇒ ED2)(implicit arg0: ClassTag[ED2]): Graph[VD, ED2]

Transforms each edge attribute in the graph using the map function.

def mapTriplets[ED2](map: (EdgeTriplet[VD, ED]) ⇒ ED2, tripletFields: TripletFields)(implicit arg0: ClassTag[ED2]): Graph[VD, ED2]

Transforms each edge attribute using the map function, passing it the adjacent vertex attributes as well.

def mapTriplets[ED2](map: (EdgeTriplet[VD, ED]) ⇒ ED2)(implicit arg0: ClassTag[ED2]): Graph[VD, ED2]

Transforms each edge attribute using the map function, passing it the adjacent vertex attributes as well.

val ops: GraphOps[VD, ED]

The associated GraphOps object.

Reference:

https://github.com/apache/spark/blob/v2.4.5/graphx/src/main/scala/org/apache/spark/graphx/Graph.scala

Last updated