鲲鹏社区首页
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

K-Core

run API

  • API
    def run(edgeList: RDD[(Long, Long)]): RDD[(Long, Int)]
  • 功能描述

    计算图中所有结点的coreness值。本算法的输入为无权无向图,输入仅需输入单向边(1L, 2L),无需包含(2L, 1L)。

  • API描述
    1. 包名:package org.apache.spark.graphx.lib.KCoreDecomposition
    2. 类名:KCoreDecomposition
    3. 方法名:run
    4. 输入:

      edgeList: RDD[(Long, Long)]

    5. 参数详情:

      参数名称

      取值类型

      描述

      edgeList

      RDD[(Long, Long)]

      从文件中读入后的边列表数据

    6. 输出:coreness: RDD[(Long, Int)],其中(Long, Int)分别保存结点ID及其对应的coreness值。
  • 使用样例

    KCoreDecomposition样例:

    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)