spark graphx 图结构 画图/可视化

2024-06-23 04:48

本文主要是介绍spark graphx 图结构 画图/可视化,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

所需的包: maven包:
<!--&lt;!&ndash; https://mvnrepository.com/artifact/org.graphstream/gs-core &ndash;&gt;-->
<dependency><groupId>org.graphstream</groupId><artifactId>gs-core</artifactId><version>1.2</version>
</dependency><!--&lt;!&ndash; https://mvnrepository.com/artifact/org.graphstream/gs-ui &ndash;&gt;-->
<dependency><groupId>org.graphstream</groupId><artifactId>gs-ui</artifactId><version>1.2</version>
</dependency><!--&lt;!&ndash; https://mvnrepository.com/artifact/org.scalanlp/breeze &ndash;&gt;-->
<dependency><groupId>org.scalanlp</groupId><artifactId>breeze_2.11</artifactId><version>0.12</version>
</dependency><!--&lt;!&ndash; https://mvnrepository.com/artifact/org.scalanlp/breeze-viz &ndash;&gt;-->
<dependency><groupId>org.scalanlp</groupId><artifactId>breeze-viz_2.11</artifactId><version>0.12</version>
</dependency><!--&lt;!&ndash; https://mvnrepository.com/artifact/org.jfree/jcommon &ndash;&gt;-->
<dependency><groupId>org.jfree</groupId><artifactId>jcommon</artifactId><version>1.0.24</version>
</dependency><!-- https://mvnrepository.com/artifact/org.jfree/jfreechart -->
<dependency><groupId>org.jfree</groupId><artifactId>jfreechart</artifactId><version>1.0.19</version>
</dependency>

运行代码:

package net.qihoo.antispam.personal.graphximport org.apache.spark.graphx.{Edge, Graph, VertexId}
import org.apache.spark.{SparkConf, SparkContext}
import org.graphstream.graph.implementations.{AbstractEdge, SingleGraph, SingleNode}object playGraph{def main(args: Array[String]): Unit = {val sparkConf = new SparkConf().setAppName("GraphStreamDemo").set("spark.master", "local[*]")val sc = new SparkContext(sparkConf)val graph: SingleGraph = new SingleGraph("graphDemo")val vertices = sc.parallelize(List((1L, "ip"),(2L, "user"),(3L, "device")))val edges = sc.parallelize(List(Edge(1L, 2L, "1-2"),Edge(1L, 3L, "1-3"),Edge(2L, 3L, "2-4")))val srcGraph = Graph(vertices, edges)graph.setAttribute("ui.stylesheet", "url(file:XXX/mystylesheets)")graph.setAttribute("ui.quality")graph.setAttribute("ui.antialias")//    load the graphx vertices into GraphStreamfor ((id, name) <- srcGraph.vertices.collect()){val node = graph.addNode(id.toString).asInstanceOf[SingleNode]node.addAttribute("ui.label",name)}//    load the graphx edges into GraphStream edgesfor (Edge(x, y, info) <- srcGraph.edges.collect()){val edge = graph.addEdge(x.toString ++ y.toString, x.toString, y.toString, true).asInstanceOf[AbstractEdge]edge.addAttribute("ui.label",info)}graph.display()}结果图:

节点指定颜色见后面的文档

这篇关于spark graphx 图结构 画图/可视化的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1086226

相关文章

可视化实训复习篇章

前言: 今天,我们来学习seaborn库可视化,当然,这个建立在Matplotlib的基础上,话不多说,进入今天的正题吧!当然,这个是《python数据分析与应用》书中,大家有需求的可以参考这本书。 知识点: Matplotlib中有两套接口分别是pyplot和pyylab,即绘图时候主要导入的是Matplotlib库下的两个子模块(两个py文件)matplotlib.pyplot和matp

Windows/macOS/Linux 安装 Redis 和 Redis Desktop Manager 可视化工具

本文所有安装都在macOS High Sierra 10.13.4进行,Windows安装相对容易些,Linux安装与macOS类似,文中会做区分讲解 1. Redis安装 1.下载Redis https://redis.io/download 把下载的源码更名为redis-4.0.9-source,我喜欢跟maven、Tomcat放在一起,就放到/Users/zhan/Documents

【第十三课】区域经济可视化表达——符号表达与标注

一、前言 地图最直接的表达就是使用符号表达。使用符号可以把简单的点线面要 素渲染成最直观的地理符号,提高地图的可读性。只要掌握了 ArcGIS 符号制 作的技巧,分析符号并总结出规则,就可以制作符合要求的地图+符号。 (一)符号的选择与修改 符号的选择在制图中至关重要,使用符号选择器对话框可从多个可用样式 中选择符号,并且每个符号都有一个标签用来描述其图形特征,如颜色或类型, 利用这些标签可

百度OCR识别结构结构化处理视频

https://edu.csdn.net/course/detail/10506

微信小程序开发必知必会:文件结构和基本配置

一、微信小程序基本文件结构 1.  project.config.json:项目的基本配置文件,包括项目名称、appid、项目目录、页面文件夹等。     {"setting": {"urlCheck": false,"es6": true,"postcss": true,"nodeModulesPath": "D:\\\\node_modules"},"appid": "wxd678e

利用结构体作为函数参数时结构体指针的定义

在利用结构体作为函数的参数进行传递时,容易犯的一个错误是将一个野指针传给函数导致错误。 #include <stdio.h>#include <math.h>#include <malloc.h>#define MAXSIZE 10typedef struct {int r[MAXSIZE]; //用于存储要排序的数组,r[0]作为哨兵或者临时变量int length;

openfire+spark 在linux下安装,配置

文章转自:点击打开链接 相关软件下载 链接: https://pan.baidu.com/s/1boJs61h 密码: 2wd7 Openfire 在linux下安装和配置 + spark 在windows下配置 本机环境 系统:CentOS 6.7 64 位JDK 1.7 64 位MySQL 5.6 Openfir

学习VXLAN -- 报文结构、原理和配置

目录 VXLAN背景什么是VXLANVXLAN的优势VXLAN报文结构一些特定名词BDVBDIFVAPVSIVSI-InterfaceAC VXLAN的实现原理图VXLAN MAC地址表项MAC地址动态学习 VXLAN隧道VXLAN隧道工作模式L2 GatewayIP Gateway VXLAN隧道的建立与关联VXLAN隧道建立的方式VXLAN对到与VXLAN关联的方式 配置VXLAN接入

【python】python葡萄酒国家分布情况数据分析pyecharts可视化(源码+数据集+论文)【独一无二】

👉博__主👈:米码收割机 👉技__能👈:C++/Python语言 👉公众号👈:测试开发自动化【获取源码+商业合作】 👉荣__誉👈:阿里云博客专家博主、51CTO技术博主 👉专__注👈:专注主流机器人、人工智能等相关领域的开发、测试技术。 python葡萄酒国家分布情况数据分析pyecharts可视化(源码+数据集+论文)【独一无二】 目录 python葡

任务5.1 初识Spark Streaming

实战概述:使用Spark Streaming进行词频统计 1. 项目背景与目标 背景: Spark Streaming是Apache Spark的流处理框架,用于构建可伸缩、高吞吐量的实时数据处理应用。目标: 实现一个实时词频统计系统,能够处理流式数据并统计文本中的单词出现频率。 2. 技术要点 Spark Streaming集成: 与Spark生态的其他组件如Spark SQL、ML