【问题标题】:Normalized degree centrality measures with isolated vertices/nodes (r igraph)具有孤立顶点/节点的归一化度中心性度量(r igraph)
【发布时间】:2020-11-02 18:09:41
【问题描述】:

我对网络分析很陌生。我想用 R 计算归一化中心性度量(度、介数和特征向量)。我创建了以下边列表,其中 ID1 和 ID2 都是投资者。如果 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"))

为了计算归一化度中心性,我使用以下代码:

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

如您所见,Warning message 出现:它将 NA 视为单独的投资者(它将 NA 变成一个字符串)。我保持孤立投资者的原因是标准化需要将原始程度度量(使用连接的节点/投资者计算的)除以任何投资者可能投资的投资者的可能数量(即所有可能的投资者,计算那些投资的投资者)单独)。

关于如何规避此类问题的任何建议?我尝试使用邻接矩阵,但也无法弄清楚...

非常感谢!

【问题讨论】:

  • 有点不清楚您要达到的目标。网络由通过边连接或不连接的节点组成。一个总是独自投资的投资者的“程度”是什么?我猜,它是一个没有连接的节点,所以应该是零?

标签: r igraph adjacency-matrix edge-list


【解决方案1】:

当使用igraph时,处理与其他节点没有连接的节点的正确方法是传入一个顶点列表。使用您提供的数据:

# 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

【讨论】:

  • 谢谢@desval。您在na.omit(edgelist) 上的第二步确实删除了任何具有 NA 值的观察结果。然后你分析一个没有孤立节点/顶点的网络。我终于做了后者并手动将 degree=0 添加到这样的孤立节点
  • 不确定“分析没有孤立节点的网络”是什么意思。如您在示例中所见,所有节点都返回度数,包括没有边的节点。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-07-29
  • 2015-08-03
  • 2014-07-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多