Graphx可视化 [英] Graphx Visualization

查看:202
本文介绍了Graphx可视化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来可视化Spark的Graphx中构造的图形.据我所知,Graphx没有任何可视化方法,因此我需要将数据从Graphx导出到另一个图形库,但是我被困在这里.我遇到了这个网站: https://lintool.github.io/warcbase- docs/Spark-Network-Analysis/ 但这没有帮助.我应该使用哪个库以及如何导出图形.

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.

推荐答案

因此您可以执行以下操作

So you can do something like this

  1. 保存到gexf(图形交换格式)中的代码来自 Manning | Spark GraphX的实际应用

def toGexf[VD,ED](g:Graph[VD,ED]) : String = {
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
    "<gexf xmlns=\"http://www.gexf.net/1.2draft\" version=\"1.2\">\n" +
    "  <graph mode=\"static\" defaultedgetype=\"directed\">\n" +
    "    <nodes>\n" +
    g.vertices.map(v => "      <node id=\"" + v._1 + "\" label=\"" +
                        v._2 + "\" />\n").collect.mkString +
    "    </nodes>\n" +
    "    <edges>\n" +
    g.edges.map(e => "      <edge source=\"" + e.srcId +
                     "\" target=\"" + e.dstId + "\" label=\"" + e.attr +
                     "\" />\n").collect.mkString +
    "    </edges>\n" +
    "  </graph>\n" +
    "</gexf>"
}

  1. 使用 linkurious.js 中的GEXF插件加载文件
  1. Use the GEXF plugin in linkurious.js to load the file

示例: http://gregroberts.github.io

这篇关于Graphx可视化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆