简体   繁体   English

使用 igraph 在 bipartite.networks 上工作:基本度量的问题(密度、归一化程度)

[英]Working on bipartite networks with igraph : problem with basic measures (density, normalized degree)

I'm new to bipartite.network analysis and i've some trouble with basic measures.我是 bipartite.network 分析的新手,我在基本测量方面遇到了一些麻烦。 I'm trying to work on bipartite.networks without projecting in 1-mode graphs .我正在尝试在不投影 1-mode graphs 的情况下处理 bipartite.networks 。 My problems come from the fact that the igraph package allows to create bipartite graphs but that the measures do not seem to adapt to the specificity of these graphs.我的问题来自igraph package 允许创建二分图但这些措施似乎不适应这些图的特殊性。

So, my general question is how do you do when you work directly on bipartite.networks?所以,我的一般问题是当你直接在 bipartite.networks 上工作时你会怎么做?

Here a concrete exemple with density这是一个密度的具体例子

## 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

But the bipartite package is very specific to ecology fields and lot of measures are designed to food web and interaction between species (and some, like clustering coefficient, don't seem to take into account the bipartite nature of the graph: eg compute 4-cycles).但是二分法package 是非常特定于生态学领域的,很多措施都是针对食物 web 和物种之间的相互作用而设计的(有些,比如聚类系数,似乎没有考虑到图的二分法性质:例如计算 4-周期)。

So, are there simpler ways to work on bipartite.networks with igraph ?那么,是否有更简单的方法可以使用igraph在 bipartite.networks 上工作? To measure some global indexes (density, clustering coefficient with 4-cycles, I know that .net does this but my actual.networks are too large), and to normalize local indexes like degree, closeness, betweenness centralities taking into account the bipartite specificity (like in Borgatti SP, Everett MG, 1997, « Network analysis of 2-mode data », Social Networks)?要测量一些全局指标(密度、4 周期的聚类系数,我知道.net 会这样做,但我的实际网络太大),并在考虑二分特异性的情况下标准化局部指标,如度数、紧密度、中间性中心性(就像 Borgatti SP, Everett MG, 1997, « 2-mode data 的网络分析 », Social Networks)?

Any advice will be appreciated !任何建议将被认真考虑 !

Below the code to reproduce the sample of my matrix "m"在代码下面重现我的矩阵“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, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 
0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 
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, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 
0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 
0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 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, 1, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 
1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 
0, 0, 0, 1, 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, 0, 0, 0, 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")))

Density: you already got it密度:你已经知道了

Degree degv1 <- degree(g, V(g)[type == FALSE]) degv2 <- degree(g, V(g)[type == TRUE])度数 degv1 <- 度数 (g, V(g)[type == FALSE]) degv2 <- 度数 (g, V(g)[type == TRUE])

Normalized degree: divise by the vcount of the other node category归一化度数:除以其他节点类别的vcount

degnormv1 <- degv1/length(V(g)[type == TRUE]) degnormv2 <- degv2/length(V(g)[type == FALSE]) degnormv1 <- degv1/length(V(g)[type == TRUE]) degnormv2 <- degv2/length(V(g)[type == FALSE])

No answer regarding closeness, betweenness nor clustering coefficient没有关于亲密度、介数或聚类系数的答案

For the normalized degree, here a solution without igraph对于归一化程度,这里有一个没有 igraph 的解决方案

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

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

but that leaves the other questions about centrality measures open...但这留下了关于中心性措施的其他问题......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM