0

I've been trying to use the igraph package in R to graph a network where every pair of nodes has a weighted relationship between -4 and 4 (-4 meaning "as far apart as possible") When I plotted the data initially, I was able to use the weight to annotate the link thickness, but not affect the layout. Pruning the "worst" edges helps a bit, but then causes weakly linked nodes to fall off the graph, see #64 and #119 this example, and doesn't seem to move "low" value nodes apart very well. What I want, eventually, is to have the nodes plotted as close to "similar" nodes, and as far from different nodes. (edit: changing the Weight to weight in the datafile has helped, will reformulate question to more clearly ask) enter image description here

my code is and I sample datefiles are here: https://www.dropbox.com/s/kuqo3a8twa149gd/paris_rouen.zip?dl=0

datefile_base <- "paris_rouen_utrecht"
nodes <- read.csv(paste(datefile_base, "-nodes.csv", sep=""), header=T, as.is=T)

links <- read.csv(paste(datefile_base, "-edge.csv", sep=""), header=T, as.is=T)
library(igraph)
require(stats)

net <- graph_from_data_frame(d=links, vertices=nodes, directed=F) 
simplify(net, edge.attr.comb=list(weight="sum","ignore"))
translucent <- rainbow(5, alpha=.5)
V(net)$color <- translucent[V(net)$UseNumber]

plot.new
cut.off <- quantile(links$Weight)["75%"] 
net.sp <- delete_edges(net, E(net)[Weight<cut.off])
layout_with_fr(net.sp)
plot(net.sp) 
legend("topleft", c("Paris","Rouen", "Utrecht", "Unknown"), pch=21,
       col="#777777", pt.bg=translucent, pt.cex=2, cex=.8, bty="n", ncol=1)
amacks
  • 80
  • 5
  • I'm not sure I actually see a question here. Perhaps you could edit your post to make it more clear what you are asking. Also, it's easier to help if you you include a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) in the question itself that doesn't require downloading a separate file from an external site. We don't need your real data, just something to use to test the code. – MrFlick Jul 05 '18 at 18:40
  • 1
    `layout_with_fr` should use weights by default BUT it will look for a variable called `weight` Not `Weight`. – G5W Jul 05 '18 at 18:41

0 Answers0