I am looking for a way to visualize the graph constructed in Spark's Graphx. As far as I know Graphx doesn't have any visualization methods so I need to export the data from Graphx to another graph library, but I am stuck here. I ran into this website: https://lintool.github.io/warcbase-docs/Spark-Network-Analysis/ but it didn't help. Which library I should use and how to export the graph.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
由 翻译强力驱动
问题:
回答1:
So you can do something like this
- Save to gexf (graph interchange format) Code from Manning | Spark GraphX in Action
def toGexf[VD,ED](g:Graph[VD,ED]) : String = { "\n" + "
\n" + " " }\n" + " \n" + "\n" + g.vertices.map(v => " \n" + "\n").collect.mkString + " \n" + g.edges.map(e => " \n" + "\n").collect.mkString + "
- Use the GEXF plugin in linkurious.js to load the file
Example: http://gregroberts.github.io
回答2:
you can use either Gephi or d3
from zeppelin. Check D3.js In Action by Elijah Meeks
and Spark GraphX in Action by Michael S. Malak
Give it a go as below from zeppelin in scala
and js
borrowed from grapxInAction:
import org.apache.spark.graphx._ import scala.reflect.ClassTag def drawGraph[VD:ClassTag,ED:ClassTag](g:Graph[VD,ED]) = { val u = java.util.UUID.randomUUID val v = g.vertices.collect.map(_._1) println("""%html