R iGraph:双向边情况下的度

R iGraph:双向边情况下的度,r,igraph,degrees,R,Igraph,Degrees,我注意到iGraph中的函数degree,无论何时涉及双向边,都不允许直接计算有向图的无向骨架图的阶数。 比如说, g <-graph_from_literal( a-+b,a++c,d-+a,a-+e,a-+f ) d1 <- degree(g,v='a',mode="all") # 6 nn <- unique(neighbors(g,'a',mode='all')) d2 <- length(nn) # 5 g创建图的无向副本,将无向图中的多条边折叠为一条边,然

我注意到iGraph中的函数
degree
,无论何时涉及双向边,都不允许直接计算有向图的无向骨架图的阶数。 比如说,

g <-graph_from_literal( a-+b,a++c,d-+a,a-+e,a-+f )

d1 <- degree(g,v='a',mode="all")
# 6
nn <- unique(neighbors(g,'a',mode='all'))
d2 <- length(nn)
# 5

g创建图的无向副本,将无向图中的多条边折叠为一条边,然后计算其度数:

> g2 <- as.undirected(g, mode="collapse")
> degree(g2)
>g2度(g2)