【发布时间】:2021-04-07 05:13:23
【问题描述】:
我的目标是使用 igraph 计算道路网络上城市的中介中心性。首先,我使用 shp2graph 包中的 points2network 函数将城市节点放在道路网络上。然后我使用 nel2igraph 函数将网络转换为 igrah 数据。 比如网络是g1。
set.seed(123)
D <- read.table(
sep=',',
header=T,
text=
'from,to, length
A,B,5
A,C,2
D,E,3
F,G,1
H,I,6
B,H,8
D,A,4
F,B,7
')
g1 <- graph.data.frame(D,directed=F)
plot(g1)
网络是这样的:
在这个网络中,E、C、B、I 是城市。其他节点是最初来自道路网络的点。当我将中间函数与 igraph 一起使用时,它将包括网络中的所有节点。但我只需要计算城市节点。城市的关系应该像g2:
D <- read.table(
sep=',',
header=T,
text=
'from,to,length
E,C,9
E,B,12
B,C,7
B,I,14
')
g2 <- graph.data.frame(D,directed=F)
plot(g2)
有没有人知道一种方法来计算城市的介数?谢谢!
【问题讨论】:
标签: r igraph network-analysis