无论从对象“d”中选择什么字母,我都试图为节点 6 和 7 着色。
g <- graph_from_literal(1:2:3:4:5 -- 6:7)
# Rename (sum up all the vertices)
d <- c("a", "b", "c", "d", "e", "f", "g","h", "i", "j")
V(g)$name <- sample(d, 7, replace=TRUE)
colours <- c("red")
V(g)$color <- ifelse(V(g)$name == c('a','e'), "white", colours)
plot.igraph(g, layout=layout_with_dh, vertex.label=V(g)$name,
vertex.size=35,
vertex.color=V(g)$color, #colors.r
vertex.label.cex=0.7,
)
我尝试了上面的 ifelse() 但它们似乎没有数值。我会很感激一些帮助。
我想要的是节点 6 是白色的,7 是绿色的,其他节点是红色的。
谢谢!