【问题标题】:Working on bipartite networks with igraph : problem with basic measures (density, normalized degree)使用 igraph 处理二分网络:基本度量问题(密度、归一化度)
【发布时间】:2020-09-30 00:16:22
【问题描述】:

我是双向网络分析的新手,我在基本测量方面遇到了一些麻烦。 我正在尝试在二分网络上工作不投影 1 模式图。 我的问题来自 igraph 包允许创建二分图但这些措施似乎不适应这些图的特殊性的事实。

所以,我的一般问题是,当您直接在二分网络上工作时,您会怎么做?

这里有一个密度的具体例子

## Working with an incidence matrix (sample) with 47 columns and 10 rows (unweighted / undirected)
# Want to compute basic global index like density with igraph
library(igraph)
g <- graph.incidence(m, directed = F )
graph.density(g) # result = 0.04636591

# Now trying to compute basic density for a bipartite graph without igraph (number of edges divided  by the product of the two types of vertices)
library(Matrix)
d <- nnzero(m)/ (ncol(m)*nrow(m)) # result 0.1574468

# It seems that bipartite package does the job 
library(bipartite)

networklevel(m, index=c("connectance")) # result 0.1574468

但是 bipartite 包对生态领域非常具体,并且许多措施旨在食物网和物种之间的相互作用(有些,如聚类系数,似乎没有考虑到图的二分性:eg 计算 4 个周期)。

那么,有没有更简单的方法可以使用 igraph 在二分网络上工作?测量一些全局指标(密度、4 周期的聚类系数,我知道 tnet 会这样做,但我的实际网络太大),并标准化局部指标,如度、接近度、中介中心性考虑到二分特异性(如在 Borgasti SP, Everett MG, 1997, «2-mode data 的网络分析», Social Networks 中)?

任何建议将不胜感激!

下面的代码重现我的矩阵“m”的样本

 m <- structure(c(1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 
0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0), .Dim = c(10L, 47L), .Dimnames = list(
    c("02723", "13963", "F3238", "02194", "15051", "04477", "02164", 
    "06283", "04080", "08304"), c("1185241", "170063", "10350868", 
    "217831", "2210247", "2262963", "1816670", "1848354", "2232593", 
    "146214", "1880252", "2261639", "2262581", "2158177", "1850147", 
    "2262912", "146412", "2262957", "1566083", "1841811", "146384", 
    "216281", "2220957", "1846986", "1951567", "1581130", "105343", 
    "1580240", "170654", "1796236", "1835553", "1835848", "146400", 
    "1174872", "1283240", "2253354", "1283617", "146617", "160263", 
    "2263115", "184745", "1809858", "1496747", "10346824", "148730", 
    "2262582", "146268")))

【问题讨论】:

    标签: r matrix networking igraph bipartite


    【解决方案1】:

    密度:你已经知道了

    学位 degv1

    归一化度数:除以其他节点类别的vcount

    degnormv1

    没有关于接近度、介数和聚类系数的答案

    【讨论】:

    • 感谢您的回答。您可以通过使用 `` 分隔代码块来提高可读性,请参阅 stackoverflow.com/editing-help
    • 感谢劳伦特!此外,我已经重新编码,直接在没有 igraph 的关联矩阵上工作
    【解决方案2】:

    对于归一化度,这里是没有 igraph 的解决方案

    normalizedegreeV1 <- data.frame(ND = colSums(m)/nrow(m))
    
    normalizedegreeV2 <- data.frame(ND = rowSums(m)/ncol(m))
    

    但这留下了关于中心性度量的其他问题......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-31
      • 2021-10-30
      • 2017-01-04
      • 2020-08-09
      • 2020-11-02
      • 2013-01-31
      • 1970-01-01
      • 2011-11-17
      相关资源
      最近更新 更多