Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change edge thickness in igraph plot R according to Edge Attributes

Tags:

r

igraph

I want to change the edge width of my graph to correspond to the edge.betweenness score.

 net <- read.csv("D:/SNA/R/Net.csv")
 att <- read.csv("D:/SNA/R/Att.csv")
 g <- graph.data.frame(net, vertices=att, directed=TRUE)
 pdf("Network.pdf", pointsize=8)
 plot(g, vertex.label=NA, vertex.size=3, edge.width=edge.betweenness(g))
 dev.off()

I have also tried creating the edge betweenness score as an edge weight and assigning it to edge.width argument in the plot function as follows;

plot(g, vertex.label=NA, vertex.size=3, edge.width=E(g)$width
like image 736
P Mcquiy Avatar asked Mar 10 '14 13:03

P Mcquiy


1 Answers

Your example should work. Alternatively, you can write

E(g)$weight <- edge.betweenness(g)

before the plotting function.

like image 143
Piotr Migdal Avatar answered Nov 15 '22 18:11

Piotr Migdal