我正在寻找一种使用带有R语言的igraph包在有向图中传播顶点属性的智能方法。我对网络和属性的命名并不熟悉,但我会尽我所能。
一个例子:
library(igraph)
library(dplyr)
from_to_df = data.frame(from = c("a", "b", "c", "d", "e", "f"),
to = c("c", "c", "d", "e", "g", "g")
)
attributes_i_have = c(NA, NA, NA, 2, NA, NA, 1)
attributes_i_want_to_have = c(2, 2, 2, 2, 1, 1, 1)
color = c('red', 'red', 'red', 'green', 'red', 'red', 'green')
network_i_have = graph_from_data_frame(from_to_df, directed=T) %>%
set_vertex_attr("label", value = attributes_i_have) %>%
set_vertex_attr("color", value = color)
plot(network_i_have)
正如名字所说,那就是图表,我想做一些向后传播的顶点属性来获得这样的图形:
network_i_want_to_have = graph_from_data_frame(from_to_df, directed=T)%>%
set_vertex_attr("label", value = attributes_i_want_to_have) %>%
set_vertex_attr("color", value = color)
plot(network_i_want_to_have)
感谢任何帮助。