data science

Plot for Density and Inclusiveness – R

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

One reply on “Plot for Density and Inclusiveness – R”

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s