I'm trying to analyze a network (les miserables) from the betweenness point of view.
A piece of the network is:
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
]
...
I open the network in Gephi and I made biggeer nodes using the "centrality Betweenness" attribute. Doing it I get that the node of id 11 is the one with greater betweenness.
Then I tried to do the same thing in R. So I run these commands:
> 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
Why in Gephi the node with the highest betweenness is the the node of 11 while in R the node with the highest betweenness is the node of id 12?
Why in R the node with id 11 has betweenness = 0?
I don't understand where I'm wrong..
Thank you all
Your problem is that the id's of the vertices when you've read the graph in igraph
do not necessarily correspond to the ids in your file. You don't specify how you've read the info in R, but assuming that you've done something like this,
net <- read.graph("lesmiserables.gml", format="gml")
and also assuming that I've found in google the same file as you, indeed when I calculate betweenness of node 11 I don't get the expected result,
> betValjean <- betweenness(net, v = 11, normalized = TRUE)
> betValjean
[1] 0
However node 11 is not Jean Valjean,
> get.vertex.attribute(net, "label", 11)
[1] "Labarre"
You can get the node you want like this,
> V(net)[label == "Valjean"]
+ 1/77 vertex:
[1] 12
And then the betweenness in any of this 3 ways:
> 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
Hope it helps.