Graphx Visualization

匿名 (未验证) 提交于 2019-12-03 01:25:01

问题:

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

  1. 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" +     g.vertices.map(v => "      \n").collect.mkString +     "    \n" +     "    \n" +     g.edges.map(e => "      \n").collect.mkString +     "    \n" +     "  \n" +     "" }
  1. 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 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!