繁体   English   中英

在igraph中标准化边缘权重以进行绘图(边缘权重太厚)

[英]Normalize edge weights in igraph for plotting (edge weights too thick)

如何根据边缘权重将边缘不太厚的igraph中的加权网络图标准化?

igraphg是图形对象,通过E(g)$weight权重访问边缘权E(g)$weight并通过赋值修改边权重: E(g)$weight <- new_values

要在0-1之间归一化,请尝试: E(g)$weight <- E(g)$weight / max(E(g)$weight)

这是一个可复制的示例,您可以复制和粘贴。

library(igraph)

set.seed(1) # reproducibility

# generate random graph
g <- sample_k_regular(10, k = 3, directed = FALSE, multiple = FALSE) 

# add edge weights
E(g)$weight <- sample(c(1,10,50), length(E(g)), replace = TRUE)

# view the problem
plot(g, edge.width = E(g)$weight)

在此输入图像描述

# normalize the edge weights between 0-1
E(g)$weight <- E(g)$weight / max(E(g)$weight)

# play with different values of `k` until you get a reasonable looking graph
k = 9
plot(g, edge.width = E(g)$weight * k)

在此输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM