我在 Graphx 中有以下图表
graph.vertices.foreach(println)
(6109253945443866644,"Futurama"@en)
(7558506336564503178,"AccessibleComputing"@en)
(0,null)
(-2278222762001827643,"Programming languages"@en)
(-9007336571746445204,http://dbpedia.org/resource/Category:Presocratic_philosophers)
(-3236797006683951166,http://dbpedia.org/resource/Category:Programming_languages)
(-4159090027031366209,http://dbpedia.org/resource/Anaximenes_of_Miletus)
(7722304331424482609,http://dbpedia.org/resource/Category:Futurama)
(-323898215277667127,http://dbpedia.org/resource/AccessibleComputing)
我在此图上应用了连接组件算法,其输出如下:-
ccGraph.vertices.foreach(println)
(6109253945443866644,6109253945443866644)
(7558506336564503178,-323898215277667127)
(0,0)
(-2278222762001827643,-3236797006683951166)
(-9007336571746445204,-9007336571746445204)
(-3236797006683951166,-3236797006683951166)
(-4159090027031366209,-9007336571746445204)
(7722304331424482609,6109253945443866644)
(-323898215277667127,-323898215277667127)
我找不到在 ccGraph 中找到 (vertexID,vertexID) 的顶点标签/顶点名称的方法,以便输出从
(vertexID,vertexID) => (vertexLabel,vertexLabel) 转换
我尝试了以下方法但失败了
ccGraph.vertices.map({case arr =>
val k1 = graph.vertices.lookup(arr(0))
val k2 = graph.vertices.lookup(arr(1))
(k1,k2)
})
<console>:51: error: (org.apache.spark.graphx.VertexId, org.apache.spark.graphx.VertexId) does not take parameters
ccGraph.vertices.map({case arr => val k1 = graph1.vertices.lookup(arr(0))
^
<console>:52: error: (org.apache.spark.graphx.VertexId, org.apache.spark.graphx.VertexId) does not take parameters
val k2 = graph1.vertices.lookup(arr(1))