KCore
run API
- API
def run(edgeList: RDD[(Long, Long)]): RDD[(Long, Int)]
- 功能描述
计算图中所有节点的coreness值。本算法的输入为无权无向图,输入仅需输入单向边(1L, 2L),无需包含(2L, 1L)。
- API描述
- 包名:package org.apache.spark.graphx.lib.KCoreDecomposition
- 类名:KCoreDecomposition
- 方法名:run
- 输入:edgeList: RDD[(Long, Long)]
- 参数详情:
参数名称
参数含义
取值类型
edgeList
从文件中读入后的边列表数据
RDD[(Long, Long)]
- 输出:coreness: RDD[(Long, Int)], 其中(Long, Int)分别保存节点ID及其对应的coreness值。
- 使用样例
val sc = new SparkContext(new SparkConf().setMaster("yarn").setAppName("KCore")) val inputGraphRaw = Array((1L, 2L), (3L, 2L), (3L, 1L), (4L, 5L)) val edegeList = sc.parallelize(inputGraphRaw) val res = KCoreDecomposition.run(edgeList).collectAsMap()
- 样例结果:
Res = Map(1L -> 2, 2L -> 2, 3L -> 2, 4L -> 1, 5L ->1)
父主题: 算法API