简体   繁体   English

具有孤立顶点/节点的归一化度中心性度量(r igraph)

[英]Normalized degree centrality measures with isolated vertices/nodes (r igraph)

I am quite new to network analysis.我对网络分析很陌生。 I want to compute normalized centrality measures (degree, betweenness, and eigenvector) with R.我想用 R 计算归一化中心性度量(度、介数和特征向量)。 I created the following edgelist where both ID1 and ID2 are investors.我创建了以下边缘列表,其中 ID1 和 ID2 都是投资者。 If both ID1 and ID2 are populated, investors co-invest, otherwise, the investor invests alone (ie isolated node):如果 ID1 和 ID2 都填充,投资者共同投资,否则,投资者单独投资(即孤立节点):

edgelist <- structure(list(ID1 = c("Cottonwood Capital Partners LLC", "Sequoia Capital Operations LLC", 
                   "Seraphim Capital (General Partner) LLP", "Seraphim Capital (General Partner) LLP", 
                   "Providence Equity Partners LLC", "Turn8", "Matrix Partners LP", 
                   "Zeeuws Investeringsfonds BV", "Venionaire Capital GmbH", "CincyTech", 
                   "First Round Capital", "Matrix Partners LP", "Mohr Davidow Ventures", 
                   "Esprit Capital Partners LLP", "Yaletown Venture Partners", "Wellington Partners", 
                   "Charles River Ventures LLC", "MB VENTURE PARTNERS L L C", "Edison Partners", 
                   "Ballast Point Venture Partners LLC", "Arcview Group", "Foundry Group LLC", 
                   "Sosventures LLC", "Vantagepoint Management Inc", "Bain Capital Venture Partners LLC", 
                   "NAV VC", "Bluerun Ventures LP", "Draper Fisher Jurvetson International Inc", 
                   "Claremont Creek Ventures LP", "Meritage Funds"), ID2 = c("Pangaea Ventures Ltd", 
                                                                             NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "RPM Ventures Management LLC", 
                                                                             NA, "Kennet Partners Ltd", NA, NA, "Gotham Ventures LLC", NA, 
                                                                             NA, NA, "Syncom Management Co Inc", "Lightspeed Venture Partners China Co Ltd", 
                                                                             NA, "First Round Capital", NA)), row.names = c(NA, -30L), class = c("tbl_df", 
                                                                                                                                                 "tbl", "data.frame"))

To compute normalized degree centralities, I use the following code:为了计算归一化度中心性,我使用以下代码:

library(igraph)
net <- graph.data.frame(edgelist, directed = F) # create undirected graph

"Warning message:
In graph.data.frame(edgelist, directed = F) :
In `d' `NA' elements were replaced with string "NA""

degree_norm <- degree(net, mode = "all", normalized = T) # retreive normalized degree measure
betw_norm <- betweenness(net2, directed=F, normalized = T) # retreive normalized betw measure
ev <- eigen_centrality(net2, directed = F, scale=F, weights = NULL) # retreive normalized ev

As you can see a Warning message appears: It considers the NA as a separate investor (it turns NA a string).如您所见,出现Warning message :它将NA视为单独的投资者(它将NA变为字符串)。 The reason why I keep isolated investors is that the normalization requires dividing the raw degree measure (that one computed with connected nodes/investors) by the possible number of investors to whom any investor could have invested (ie all investors possible, counting those that invest alone).我保持孤立投资者的原因是标准化需要将原始程度度量(使用连接的节点/投资者计算的)除以任何投资者可能投资的投资者的可能数量(即所有可能的投资者,计算那些投资的投资者)独自的)。

Any suggestion on how to circumvent such problem?关于如何规避此类问题的任何建议? I tried to work with adjacency matrices, but could not figure it out either...我尝试使用邻接矩阵,但也无法弄清楚......

Thanks a lot!非常感谢!

When using igraph , the correct way of dealing with nodes that have no connection to other nodes is passing in a list of vertices.使用igraph时,处理与其他节点没有连接的节点的正确方法是传入一个顶点列表。 Using the data you provided:使用您提供的数据:

# first get a list of all the nodes, excluding the NA
nodeslist <- data.frame(name= na.omit(unique(c(edgelist$ID1,edgelist$ID2 ))))

# delete the NAs from the edge list
edgelist <- na.omit(edgelist)

# create the `igraph` object
g <- graph_from_data_frame(edgelist,
                           directed = F,
                           vertices = nodeslist)

# compute normalized degree
V(g)$degree <- igraph::degree(g, mode = "all", normalized = T)

# explore the result: there are 34 nodes, and the (not-normalized) degree of all nodes
# is either 0 or 1. Therefore, the normalized degree should be either 1/33=0.03030303 or 0:
V(g)$degree
 [1] 0.03030303 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
 [8] 0.00000000 0.00000000 0.03030303 0.00000000 0.00000000 0.00000000 0.00000000
[15] 0.03030303 0.00000000 0.03030303 0.00000000 0.00000000 0.03030303 0.00000000
[22] 0.00000000 0.00000000 0.03030303 0.03030303 0.00000000 0.03030303 0.00000000
[29] 0.03030303 0.03030303 0.03030303 0.03030303 0.03030303 0.03030303

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

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