有没有办法在邻域函数中应用限制:
http://igraph.sourceforge.net/doc/R/neighborhood.html
仅获取通过给定边缘阈值连接的邻居?例如:
谢谢!
答案 0 :(得分:1)
如果我理解正确,那么您可以做的就是限制权重的原始图表的子集。
> library(igraph)
> df <- data.frame(
a = c("n1","n1","n1","n1","n2"),
b = c("n2","n3","n4","n5","n3"),
w = c(-1,1,-1,1,-1))
> g <- graph.data.frame(df, directed=FALSE)
> plot(g, edge.label=E(g)$w)
[img #1]
# restrict graph to edges with value w being negative
> subg <- graph.neighborhood(
subgraph.edges(g, eids = which(E(g)$w < 0)),
order = 1)
> subg
[[1]]
IGRAPH UN-- 3 2 --
+ attr: name (v/c), w (e/n)
[[2]]
IGRAPH UN-- 3 2 --
+ attr: name (v/c), w (e/n)
[[3]]
IGRAPH UN-- 2 1 --
+ attr: name (v/c), w (e/n)
[[4]]
IGRAPH UN-- 2 1 --
+ attr: name (v/c), w (e/n)
> plot(subg[[1]], edge.label=E(subg[[1]])$w)
[img #2]