- API
graph.degrees
graph.inDegrees
graph.outDegrees
- 功能描述
根据指定输入图,计算图中所有节点的度中心性值,与开源接口保持一致。
- API描述
- 方法名:inDegree,outDegree,Degree
- 输入:
graph: Graph[VD, ED],为基于输入数据集构建的图。
- 参数详情:
参数名称
|
参数含义
|
取值类型
|
graph
|
已构建完成的图
|
Graph[VD, ED]
|
- 输出:VertexRDD[Int],为图中节点编号,与每个节点对应的度中心性的值组成的列表。
- 使用样例
Degree样例:
val sparkconf = new SparkConf().setAppName("DegreeCompute").setMaster(host)
val sc = new SparkContext(sparkconf)
val edges = sc.parallelize(Array((1L,2L),(1L,3L),(2L,3L)))
val graph = Graph.fromEdgeTuples(edges, 0)
val resDegrees = graph.degrees
val resInDegrees = graph.inDegrees
val resOutDegrees = graph.outDegrees
- 样例结果
resDegrees=[ (1,2)(3,2)(2,2)]
resInDegrees=[ (3,2)(2,1)]
resOutDegrees=[ (1,2)(2,1)]