Why the graph is not proper in R?

时间:2018-06-04 16:56:27

标签: r igraph

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.

enter image description here

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 个答案:

答案 0 :(得分:1)

无论出于何种原因,系统上的默认箭头大小似乎太大。可以在plot语句中指定箭头大小。示例: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)

来自类似问题:igraph - plotting directed network creates triangular edges