graphx java_Spark GraphX图处理编程实例

本文介绍了Spark GraphX中的图处理功能,包括图的基本属性如顶点、边的数量,度数,以及如何缓存图、改变分区策略。此外,还涉及到图的转换操作,如映射顶点和边的属性,逆向图,子图筛选,以及图的连接、聚合信息和迭代计算。文章涵盖的重要算法有PageRank、强连通组件、三角计数等。
摘要由CSDN通过智能技术生成

/**Summary of the functionality in the property graph*/

classGraph[VD, ED] {//Information about the Graph ===================================================================

val numEdges: Long

val numVertices: Long

val inDegrees: VertexRDD[Int]

val outDegrees: VertexRDD[Int]

val degrees: VertexRDD[Int]//Views of the graph as collections =============================================================

val vertices: VertexRDD[VD]

val edges: EdgeRDD[ED]

val triplets: RDD[EdgeTriplet[VD, ED]]//Functions for caching graphs ==================================================================

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

def cache(): Graph[VD, ED]

def unpersistVertices(blocking: Boolean= true): Graph[VD, ED]//Change the partitioning heuristic ============================================================

def partitionBy(partitionStrategy: PartitionStrategy): Graph[VD, ED]//Transform vertex and edge attributes ==========================================================

def mapVertices[VD2](map: (VertexID, VD) =>VD2): Graph[VD2, ED]

def mapEdges[ED2](map: Edge[ED]=>ED2): Graph[VD, ED2]

def mapEdges[ED2](map: (PartitionID, Iterator[Edge[ED]])=>Iterator[ED2]): Graph[VD, ED2]

def mapTriplets[ED2](map: EdgeTriplet[VD, ED]=>ED2): Graph[VD, ED2]

def mapTriplets[ED2](map: (PartitionID, Iterator[EdgeTriplet[VD, ED]])=>Iterator[ED2])

: Graph[VD, ED2]//Modify the graph structure ====================================================================

def reverse: Graph[VD, ED]

def subgraph(

epred: EdgeTriplet[VD,ED]=> Boolean = (x => true),

vpred: (VertexID, VD)=> Boolean = ((v, d) => true))

: Graph[VD, ED]

def mask[VD2, ED2](other: Graph[VD2, ED2]): Graph[VD, ED]

def groupEdges(merge: (ED, ED)=>ED): Graph[VD, ED]//Join RDDs with the graph ======================================================================

def joinVertices[U](table: RDD[(VertexID, U)])(mapFunc: (VertexID, VD, U) =>VD): Graph[VD, ED]

def outerJoinVertices[U, VD2](other: RDD[(VertexID, U)])

(mapFunc: (VertexID, VD, Option[U])=>VD2)

: Graph[VD2, ED]//Aggregate information about adjacent triplets =================================================

def collectNeighborIds(edgeDirection: EdgeDirection): VertexRDD[Array[VertexID]]

def collectNeighbors(edgeDirection: EdgeDirection): VertexRDD[Array[(VertexID, VD)]]

def aggregateMessages[Msg: ClassTag](

sendMsg: EdgeContext[VD, ED, Msg]=>Unit,

mergeMsg: (Msg, Msg)=>Msg,

tripletFields: TripletFields=TripletFields.All)

: VertexRDD[A]//Iterative graph-parallel computation ==========================================================

def pregel[A](initialMsg: A, maxIterations: Int, activeDirection: EdgeDirection)(

vprog: (VertexID, VD, A)=>VD,

sendMsg: EdgeTriplet[VD, ED]=>Iterator[(VertexID,A)],

mergeMsg: (A, A)=>A)

: Graph[VD, ED]//Basic graph algorithms ========================================================================

def pageRank(tol: Double, resetProb: Double = 0.15): Graph[Double, Double]

def connectedComponents(): Graph[VertexID, ED]

def triangleCount(): Graph[Int, ED]

def stronglyConnectedComponents(numIter: Int): Graph[VertexID, ED]

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值