1
votes

I have a xlsx contains about 2000+ nodes and 9000 edges. And I want to generate a explicit directed graph. I tried igraph package in R to generate the directed graph I want but (1) it is too many nodes and edges to print clearly.I refer some documents that using networkd3 to convert igraph to networkd3 and plot,but(2) the direction(arrows) lost. Would you please help me out these sitution? Either (1) or (2).My codes belows,and my data format like edges1.xlsx source target attr s1 s2 a s2 s7 b s2 s3 c

nodes1.xlsx id attr s1 a s2 c s3 d s4 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.....

Is there any solutions to solve these problems?

1

1 Answers

2
votes
  1. A network graph with 2000+ nodes and 9000 edges is going to be messy no matter which software you use to generate it. What do you hope will be different if you plot it with networkD3?

  2. UPDATE (2017.03.24): This feature (using arrowheads to show the direction of edges/links) is in the most recent released version (0.4) of networkD3 with the arrows = TRUE argument to forceNetwork().