我本以为图算法会自动获取边缘数据框中的列权重,但事实并非如此,如以下代码所示:
nodes <- data.frame(name = c("1", "2", "3"), type = c("a", "b", "b"))
edges <- data.frame(from = c("1", "1"), to = c("2", "3"), weight = c(10000, 50))
net <- graph_from_data_frame(edges, directed=FALSE, vertices=nodes)
V(net)$size <- 2
V(net)$color <- ifelse(V(net)$type == "a", "darkblue", "orange")
V(net)$shape <- ifelse(V(net)$type == "a", "circle", "square")
plot(net)
有没有办法使用边缘数据框中专门命名的列(例如权重)来设置所描绘边缘的厚度?谢谢!
最佳答案
您可以尝试下面的代码
E(net)$width <- edges$weight
plot(net)
关于r - 改变 igraph 网络中边的权重,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65312638/