This function will color all the nodes that are isolated in red. It will also draw the graph using the circle layout.
No time to explain. Sorry.
The Function
plot.color.graph <- function(g,graph_label){ #size of vertices V(g)$size <- 2 V(g)$label <- '' deg_list <- degree(g) g_df <- data.frame(deg_list) g_df$color <- 'white' g_df$frame.color <- 'black' g_df$color[g_df$deg_list != 0] <- 'black' g_df$frame.color[g_df$deg_list == 0] <- 'red' V(g)$color <- g_df$color V(g)$frame.color <- g_df$frame.color plot(g,main=graph_label,layout=layout.circle) }
One reply on “Plot for Density and Inclusiveness – R”
This is a nice code snippet. Very nice work