[R] igraph: error when setting size and shape of vertices

robbie.heremans at telenet.be robbie.heremans at telenet.be
Wed Feb 4 11:26:28 CET 2009

```When the shape of all vertices is set to "square" and the size of the vertices is also set, one get following error (commands attached):

Error in l[[which.min(sapply(l, function(p) (p[1] - x0)^2 + (p[2] - y0)^2))]] :
attempt to select less than one element

Is there a way to solve this problem?

Robbie

library(igraph)

## Create and plot a small graph
g <- graph( c(0,1, 0,2, 1,2, 2,3), n=4, directed = FALSE)
plot(g)

V(g)\$size<-c(10,15,20,30)
plot(g) #OK

V(g)\$shape<-c("circle","circle","circle","square")
plot(g) #OK

V(g)\$shape<-c("circle","circle","square","square")
plot(g) #OK

V(g)\$shape<-c("circle","square","square","square")
plot(g) #OK

V(g)\$shape<-c("square","square","square","square")
plot(g) #Error in l[[which.min(sapply(l, function(p) (p[1] - x0)^2 + (p[2] - y0)^2))]] :
#attempt to select less than one element

V(g)\$shape<-c("square","square","circle","square")
plot(g) #OK

## Same without changing size
g <- graph( c(0,1, 0,2, 1,2, 2,3), n=4, directed = FALSE)
V(g)\$shape<-c("square","square","square","square")
plot(g) #OK

```