Data Science with Apache Spark

Searchβ¦

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:

1

abstract def cache(): Graph[VD, ED]

2

Caches the vertices and edges associated with this graph at the previously-specified target storage levels, which default to MEMORY_ONLY.

3

β

4

abstract def checkpoint(): Unit

5

Mark this Graph for checkpointing.

6

β

7

abstract val edges: EdgeRDD[ED]

8

An RDD containing the edges and their associated attributes.

9

β

10

abstract def getCheckpointFiles: Seq[String]

11

Gets the name of the files to which this Graph was checkpointed.

12

β

13

abstract def groupEdges(merge: (ED, ED) β ED): Graph[VD, ED]

14

Merges multiple edges between two vertices into a single edge.

15

β

16

abstract def isCheckpointed: Boolean

17

Return whether this Graph has been checkpointed or not.

18

β

19

abstract def mapEdges[ED2](map: (PartitionID, Iterator[Edge[ED]]) β Iterator[ED2])(implicit arg0: ClassTag[ED2]): Graph[VD, ED2]

20

Transforms each edge attribute using the map function, passing it a whole partition at a time.

21

β

22

abstract def mapTriplets[ED2](map: (PartitionID, Iterator[EdgeTriplet[VD, ED]]) => Iterator[ED2], tripletFields: TripletFields)(implicit arg0: ClassTag[ED2]): Graph[VD, ED2]

23

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

24

β

25

abstract def mapVertices[VD2](map: (VertexId, VD) => VD2)(implicit arg0: ClassTag[VD2], eq: =:=[VD, VD2] = null): Graph[VD2, ED]

26

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

27

β

28

abstract def mask[VD2, ED2](other: Graph[VD2, ED2])(implicit arg0: ClassTag[VD2], arg1: ClassTag[ED2]): Graph[VD, ED]

29

Restricts the graph to only the vertices and edges that are also in other, but keeps the attributes from this graph.

30

β

31

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]

32

Joins the vertices with entries in the table RDD and merges the results using mapFunc.

33

β

34

abstract def partitionBy(partitionStrategy: PartitionStrategy, numPartitions: Int): Graph[VD, ED]

35

Repartitions the edges in the graph according to partitionStrategy.

36

β

37

abstract def partitionBy(partitionStrategy: PartitionStrategy): Graph[VD, ED]

38

Repartitions the edges in the graph according to partitionStrategy.

39

β

40

abstract def persist(newLevel: StorageLevel = StorageLevel.MEMORY_ONLY): Graph[VD, ED]

41

Caches the vertices and edges associated with this graph at the specified storage level, ignoring any target storage levels previously set.

42

β

43

abstract reverse: def Graph[VD, ED]

44

Reverses all edges in the graph.

45

β

46

abstract def subgraph(epred: (EdgeTriplet[VD, ED]) β Boolean = x => true, vpred: (VertexId, VD) β Boolean = (v, d) => true): Graph[VD, ED]

47

Restricts the graph to only the vertices and edges satisfying the predicates.

48

β

49

abstract val triplets: RDD[EdgeTriplet[VD, ED]]

50

An RDD containing the edge triplets, which are edges along with the vertex data associated with the adjacent vertices.

51

β

52

abstract def unpersist(blocking: Boolean = true): Graph[VD, ED]

53

Uncaches both vertices and edges of this graph.

54

β

55

abstract def unpersistVertices (blocking: Boolean = true): Graph[VD, ED]

56

Uncaches only the vertices of this graph, leaving the edges alone.

57

β

58

abstract vertices val VertexRDD[VD]

59

An RDD containing the vertices and their associated attributes

60

β

61

β

Copied!

Concrete methods:

1

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

2

β

3

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

4

β

5

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

6

β

7

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

8

β

9

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

10

β

11

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

12

β

13

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

14

β

15

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

16

β

17

val ops: GraphOps[VD, ED]

18

β

19

The associated GraphOps object.

Copied!

Reference:

Last modified 1yr ago

Copy link