i有一个XLSX包含约2000多个节点和9000个边缘。我想生成一个明确的有向图。我尝试了R中的Igraph软件包来生成我想要的有向图,但是(1)它的节点和边缘太多了,无法清楚地打印。我参考了一些使用NetworkD3将igraph转换为NetworkD3和绘图的文档,但是(2)方向(2)(2)箭头)丢失。您能帮我这些姿势吗?(1)或(2)。我的代码和我的数据格式EDGES1.XLSX源目标attrS1 S2 aS2 S7 bS2 S3 C
nodes1.xlsxid attrS1 aS2 cS3 dS4 C
library(readxl)
library(igraph)
links <- read_excel("C:\Users\file\Desktop\1W\edges1.xlsx",sheet=1,col_names = TRUE)
nodes <- read_excel("C:\Users\file\Desktop\1W\nodes1.xlsx",sheet=1,col_names = TRUE)
net <- graph_from_data_frame(d=links,vertices=unique(nodes$JYZH),directed = T)
plot(net, vertex.color="orange",vertex.size=.1,vertex.label=NA,vertex.label.color="black",vertex.label.dist=0,edge.arrow.size=.01)
#above work well with my data format but because it is too many nodes(2000+) and edges(9000+) to print clearly
library(networkD3)
#Use igraph to make the graph and find membership
wc <- cluster_walktrap(net)
members <- membership(wc)
#Convert to object suitable for networkD3
net_d3 <- igraph_to_networkD3(net,group = members)
forceNetwork(Links = net_d3$links, Nodes = net_d3$nodes,
Source = 'source', Target = 'target', NodeID = 'name',Group = 'group', zoom = TRUE)
#using above code of networkd3,the direction lost.....
是否有解决这些问题的解决方案?
-
无论您使用哪种软件生成它,带有2000 节点和9000个边缘的网络图都会凌乱。如果您使用NetworkD3绘制它,您希望有什么不同?
-
update(2017.03.24):此功能(使用箭头来显示边缘/链接的方向)在
arrows = TRUE
参数的最新发布版本(0.4)中到forceNetwork()
。