我正在寻找一种智能方法,使用带有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)

任何帮助表示赞赏 .