所以我想基于edge属性获取子图(请参见下面的示例)。我找到了解决方法,但是对于这样一个简单的任务而言,它却非常冗长。我正在R上使用Igraph。
示例:
比方说,我想绘制具有正加权边的子图。在下面的示例中,将消除边缘b -> g
和e -> a
my_graph <- graph_from_data_frame(
data.table( from = c("a", "b", "c", "d", "e")
, to = c("g", "g", "g", "a", "a")
, weight = c( 2, -2 , 3 , 4 , -2)))
# This does the trick but... Should be easier isn't it?
positive_graph <-
subgraph.edges( my_graph
, E(my_graph)[E(my_graph)$weight > 0])