[R] Color Nodes

Jeff Reichman
Wed, 26 Oct 2022 20:37:09 -0000

R-Help



For those of you who use igraph is there a way to highlight (color)
particular notes. For example if I want to color the "Peter" node red
and
everything else blue  or leave default) how would I do that or can I do
that. Seems as though I might create an attribute column - maybe??



Jeff



library(igraph)



# define links in data

edges <- rbind(c("Dave", "Jenny"), c("Peter",
"Jenny"), c("John", "Jenny"),
c("Dave", "Peter"), c("Dave", "John"),
c("Peter", "Sam"), c("Sam",
"Albert"), c("Peter", "John"))



# generate and plot graph

# set argument directed = FALSE in graph.edgelist() to plot an undirected
graph.

g <- graph.edgelist(edges, directed = FALSE)

plot(g, vertex.size = 1, vertex.label.dist = 0.5)


	[[alternative HTML version deleted]]