2

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

4

1 回答 1

3

在中,图形对象在igraph哪里,您可以通过分配访问边权重并修改边权重:。 gE(g)$weightE(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)

在此处输入图像描述

于 2019-06-01T19:57:14.967 回答