diff options
Diffstat (limited to 'R Scripts/plot-graph.R')
| -rwxr-xr-x | R Scripts/plot-graph.R | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/R Scripts/plot-graph.R b/R Scripts/plot-graph.R new file mode 100755 index 0000000..b6f9341 --- /dev/null +++ b/R Scripts/plot-graph.R @@ -0,0 +1,22 @@ +#### 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) |
