i want plot a graph, while a apply a loop to a dataframe algo2
that contains the nodes and for each set of nodes i affect a color.
this is my dataframe
> algo2
node Neighbors
1 34 9, 10, 14, 15, 16, 19, 20, 21, 23, 24, 27, 28, 29, 30, 31, 32, 33
2 1 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 18, 22
3 26 25
and i apply this code before plotting:
for(i in 1:nrow(algo2)){
nnn<-as.data.frame(algo2$Neighbors[i])
nnn<-as.character(nnn[,1])
aa<-as.character(algo2$node[i])
V(g)$color <- ifelse(V(g)$name %in% c(aa,nnn),
rainbow(i),
"white")
}
V(g)$shape<-
ifelse(V(g)$name %in% AllNeighbors2_algo2[,1],
"rectangle",
"circle")
V(g)$size<-ifelse(V(g)$name %in% AllNeighbors2_algo2[,1],
4,
3)
plot.igraph(g,
vertex.color=V(g)$color,
vertex.size=V(g)$size,
vertex.shape=V(g)$shape)
the problem that when i run the plot, it take only the last value, that means, that it colorate only the vertex 26
and 25
. i want that each row od dataframe take a color different to others rows. thanks for your helps.