我正试图从中间点的角度分析网络( les miserables )。
网络的一部分是:
graph
[
node
[
id 0
label "Myriel"
maincharacter 0
]
node
[
id 1
label "Napoleon"
maincharacter 0
]
node
[
id 2
label "MlleBaptistine"
maincharacter 0
]
node
[
id 3
label "MmeMagloire"
maincharacter 0
]
node
[
id 4
label "CountessDeLo"
maincharacter 0
]
node
[
id 5
label "Geborand"
maincharacter 0
]
node
[
id 6
label "Champtercier"
maincharacter 0
]
node
[
id 7
label "Cravatte"
maincharacter 0
]
node
[
id 8
label "Count"
maincharacter 0
]
node
[
id 9
label "OldMan"
maincharacter 0
]
node
[
id 10
label "Labarre"
maincharacter 0
]
node
[
id 11
label "Valjean"
maincharacter 1
]
node
[
id 12
label "Marguerite"
maincharacter 0
]
node
[
id 13
label "MmeDeR"
maincharacter 0
]
node
[
id 14
label "Isabeau"
maincharacter 0
]
...
我在Gephi中打开网络,我使用“中心间性”属性制作了更大的节点。 这样做我得到id 11的节点是具有更大介于性的节点。
然后我试着在R做同样的事情。 所以我运行这些命令:
> net <- read.graph("./dataset/lesmiserables.gml", format = c("gml"))
> bet <- betweenness(net, normalized = TRUE)
> print(bet)
[1] 0.1768421053 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
[9] 0.0000000000 0.0000000000 0.0000000000 0.5699890528 0.0000000000 0.0000000000 0.0000000000 0.0000000000
[17] 0.0406293482 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.1296445410
[25] 0.0290024187 0.0749012212 0.0237962535 0.0543315597 0.0264912281 0.0080409357 0.0000000000 0.0086402950
[33] 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0069254386
[41] 0.0000000000 0.0114875507 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0263157895
[49] 0.1651125024 0.0202106216 0.0002172097 0.0475989279 0.0003508772 0.0000000000 0.0000000000 0.1320324886
[57] 0.0000000000 0.0276612364 0.0425533568 0.0012501456 0.0000000000 0.0012501456 0.0052670299 0.0021854883
[65] 0.0307536502 0.0021854883 0.0001503759 0.0000000000 0.0049603840 0.0049603840 0.0048618042 0.0038738299
[73] 0.0000000000 0.0000000000 0.0000000000 0.0004385965 0.0000000000
> max(bet)
[1] 0.5699891
> betValjean <- betweenness(net, v = 11, normalized = TRUE)
> print(betValjean)
[1] 0
为什么在Gephi中,中间度最高的节点是11的节点,而在R中,中间度最高的节点是id 12的节点?
为什么在R中,id为11的节点的中间度= 0?
我不明白我哪里错了..
谢谢大家
答案 0 :(得分:1)
您的问题是,当您在igraph
中阅读图表时,顶点的ID不一定与文件中的ID相对应。您没有指定如何读取R中的信息,但假设您已经完成了类似的操作,
net <- read.graph("lesmiserables.gml", format="gml")
并且还假设我在google中找到了与您相同的文件,实际上当我计算节点11的中间位置时,我没有得到预期的结果,
> betValjean <- betweenness(net, v = 11, normalized = TRUE)
> betValjean
[1] 0
然而节点11不是冉阿让,
> get.vertex.attribute(net, "label", 11)
[1] "Labarre"
您可以像这样获得所需的节点,
> V(net)[label == "Valjean"]
+ 1/77 vertex:
[1] 12
然后是这3种方式中的任何一种的中介:
> betweenness(net, v =V(net)[label == "Valjean"], normalized = TRUE)
[1] 0.5699891
> betweenness(net, v = V(net)[id == 11], normalized = TRUE)
[1] 0.5699891
> betweenness(net, v = 12, normalized = TRUE)
[1] 0.5699891
希望它有所帮助。