问题
I wanted to plot the graph from the adjacency matrix. As a first step, I have tried the following code.
set.seed(1)
library('igraph');
adjm1<-matrix(sample(0:1,100,replace=TRUE,prob=c(0.9,01)),nc=10);
g1<-graph.adjacency(adjm1);
plot(g1)
But it gave me, the following graph.
What is the mistake here?
PS: I am using
Rstudio Version 1.1.442
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
回答1:
It seems for whatever reason the default arrow size on your system is too large. One can specify the arrow size in the plot statement. Example: edge.arrow.size = 0.5
set.seed(1)
library('igraph');
adjm1<-matrix(sample(0:1,100,replace=TRUE,prob=c(0.9,01)),nc=10);
g1<-graph.adjacency(adjm1);
plot(g, edge.arrow.size = 0.1)
From similar question: igraph - plotting directed network creates triangular edges
来源:https://stackoverflow.com/questions/50685421/why-the-graph-is-not-proper-in-r