标签:oca ack set 打印 cal war iso doc ast
//1.准备环境
val conf: SparkConf = new SparkConf().setAppName("_01SparkGraphx").setMaster("local[*]")
val sc: SparkContext = new SparkContext(conf)
sc.setLogLevel("WARN")
//2.准备数据
val vertexData: RDD[(VertexId, (String, String))] = sc.parallelize(Array(
(3L, ("rxin", "stu")),
(5L, ("franklin", "prof")),
(7L, ("c", "pstdoc")),
(2L, ("d", "prof"))
))
//3.准备边的数据
val edgeData: RDD[Edge[String]] = sc.parallelize(Array(
Edge(3L, 7L, "coola"),
Edge(5L, 3L, "Advisor"),
Edge(5L, 7L, "PI"),
Edge(2L, 5L, "Collage")
))
//4.构建图
val graph: Graph[(String, String), String] = Graph(vertexData,edgeData)
//5.
println("graph edges:")
graph.edges.foreach(println(_))
//打印顶点的个数
val vertices: VertexId = graph.numVertices
println("vertrex num is",vertices)
//打印边的个数
val edges: VertexId = graph.numEdges
println("edges",edges)
标签:oca ack set 打印 cal war iso doc ast
原文地址:https://www.cnblogs.com/note-djl/p/11795910.html