当前位置:   article > 正文

educoder中Spark GraphX—寻找社交媒体中的“影响力用户”

spark graphx—寻找社交媒体中的“影响力用户”

第1关:认识Pregel API

  1. import org.apache.log4j.{Level, Logger}
  2. import org.apache.spark.{SparkConf, SparkContext}
  3. import org.apache.spark.graphx._
  4. object farthest_distance{
  5. def main(args: Array[String]): Unit = {
  6. val conf = new SparkConf().setAppName("farthest distance").setMaster("local[4]")
  7. val sc = new SparkContext(conf) //屏蔽日志
  8. Logger.getLogger("org.apache.spark").setLevel(Level.WARN)
  9. Logger.getLogger("org.eclipse.jetty.server").setLevel(Level.OFF)
  10. //构造图
  11. val myVertices = sc.parallelize(Array((1L,"Ann"),(2L,"Bill"),(3L,"Diane"),(4L,"Cody"),(5L,"Adam"),(6L,"Bob")))
  12. val myEdges = sc.parallelize(Array(Edge(1L,2L,""),Edge(2L,3L,""),Edge(2L,4L,""),Edge(3L,4L,""),Edge(4L,5L,"C"),Edge(4L,6L,""),Edge(5L,6L,""))) //构造EdgeRDD
  13. val myGraph = Graph(myVertices,myEdges)
  14. //***********
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/666740
推荐阅读
相关标签
  

闽ICP备14008679号