#### plot the victims and non-victims of the network cols = rep('lightgrey',vcount(g)) #number of nodes in g cols[V(g)$vic==1] = 'red' shapes = rep('circle',vcount(g)) shapes[V(g)$vic==1] = 'square' plot(g, layout=layout.kamada.kawai, vertex.label=NA, vertex.color=cols, vertex.shape=shapes,vertex.size=2) legend('topleft', legend=c("non-victim", "victim"), pch=c(16,15), col=c("lightgrey", "red"), inset=0.1) #### plot the neighborhood of a node v = 10 v1 = unlist(neighborhood(lcc,nodes=v,order=1)) v2 = unlist(neighborhood(lcc,nodes=v,order=2)) v3 = unlist(neighborhood(lcc,nodes=v,order=3)) v3 = setdiff(v3,v2) v2 = setdiff(v2,v1) v1 = setdiff(v1,v) cols = rep('lightgrey',vcount(g)) cols[v] = 'red' cols[v1] = 'blue' cols[v2] = 'green' cols[v3] = 'black' plot(g, layout=layout.kamada.kawai, vertex.label=NA, vertex.color=cols,vertex.size=2)