graph <- tbl_graph(nodes = nodes, edges = edges, directed = F) # 转换为合适的类型 # 使用ggraph画图 ggraph(graph, layout = 'linear', circular = T) + geom_edge_fan(aes(color = correlation, width = width),strength=3) + # 画线,添加属性 scale_edge_width(range = c(1,2)) + # ...
不过,这里面 ggraph 包还可以基于 tidygraph 包使用 tbl_graph 对象来描述网络关系,几乎完全覆盖了 igraph 包的内容,当然,装这个就得装 tidyverse 全家桶。 不论哪一种对象类型,网络对象一定可以抽象出两张表,一张表保存节点的属性,另一张表保存节点间连线的属性。而对于可视化而言,节点属性表其实就是原始数据框,...
graph <- tbl_graph(nodes = nodes, edges = edges, directed =F)# 转换为合适的类型 # 使用ggraph画图 ggraph(graph, layout ='linear', circular =T) + geom_edge_fan(aes(color = correlation, width = width),strength=3) +# 画线,添加属性 scale_edge_width(range = c(1,2)) +# 设置线的...
net.tidy <- tbl_graph( nodes = nodes, edges = edges, directed = TRUE ) 使用ggraph可视化网络 library(ggraph)ggraph(net.tidy,layout="graphopt")+geom_node_point(col='gold',size=2)+# 点信息geom_edge_link(aes(width=weight),alpha=0.8)+# 边信息scale_edge_width(range=c(0.2,2))+# 控制...
# 将节点和边数据转换为图对象 graph <- tbl_graph(nodes = nodes, edges = edges, directed = FALSE) # 绘制连线图 ggraph(graph, layout = 'fr') + geom_edge_link(aes(edge_alpha = ..index..), edge_colour = "grey50") + geom_node_point(color = "blue", size = 5) + geom_node...
frame(name=unique(c(edges$from,edges$to))) nodes$degree=degree(g) g <- tbl_graph(nodes = nodes, edges = edges) # 自定义颜色映射 mycol=c("#5599FF","#00AA00","#FF8888", "#FFDD55","#DC143C","#FF8C00", "#9ACD32", "#7700FF","#00AA88", "#CCCCFF","#77DDFF","#FFD...
library(tidygraph) net.tidy <- tbl_graph( nodes = nodes, edges = edges, directed = TRUE ) 使用ggraph可视化网络 library(ggraph) ggraph(net.tidy, layout = "graphopt") + geom_node_point(col = 'gold',size = 2) + # 点信息 geom_edge_link(aes(width = weight), alpha = 0.8) + # ...
graph <- as_tbl_graph(highschool) %>% mutate(Popularity = centrality_degree(mode ='in')) # plot using ggraph ggraph(graph, layout ='kk') + geom_edge_fan(aes(alpha = stat(index)), show.legend =FALSE) + geom_node_point(aes(size = Popularity)) + ...
很多网络可视化的工具,例如 ggnetwork 包或 ggraph 包或 GGally 包的 ggnet2 函数,都支持输入的对象为 network 包或 igraph 包里定义的网络类型。不过,这里面 ggraph 包还可以基于 tidygraph 包使用 tbl_graph 对象来描述网络关系,几乎完全覆盖了 igraph 包的内容,当然,装这个就得装 tidyverse 全家桶。
sqlCreateTbl = "CREATE TABLE IF NOT EXISTS cpr.person_correlation_graph_temp(rownames STRING,ibao_person_id_x STRING, ibao_person_id_y STRING, cor_index DOUBLE,start_date STRING,end_date STRING)" result=dbSendUpdate(hiveconnection,sqlCreateTbl) ...