Change edge thickness in igraph plot R according to Edge Attributes

P Mcquiy picture P Mcquiy · Mar 10, 2014 · Viewed 22k times · Source

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

Answer

Piotr Migdal picture Piotr Migdal · May 10, 2015

Your example should work. Alternatively, you can write

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

before the plotting function.