Hi all, I am new to network analysis.
I believe I understand that Kate is on the shortest path from Edwina to Anthony, as well as from Edwina to Benedicte, so I think I understand the value of 2.
However, Anthony is indeed on the shortest path between Benedicte and Edwina in both directions (=2), and he is on the shortest path between Kate and Benedicte in both directions (=2). So, I would find the value of four for the number of shortest paths and hence the betweenness. Why then five?
I have tried other packages, and sometimes I get the following values: 4 0 0 0 or 6 0 0 0, 2 0 0 0, in short, I am confused…
Can someone help me understand?
Thank you in advance for any assistance you can provide.
Nancy
Below is the script and the dataset.
# data --------------------------------------------------------------------
(sub=tibble::tribble(
~source, ~target, ~weight,
"Anthony", "Benedicte", 3,
"Anthony", "Edwina", 1,
"Anthony", "Kate", 2,
"Benedicte", "Anthony", 4,
"Edwina", "Kate", 2,
"Kate", "Anthony", 1,
"Kate", "Edwina", 4
))
#> # A tibble: 7 × 3
#> source target weight
#> <chr> <chr> <dbl>
#> 1 Anthony Benedicte 3
#> 2 Anthony Edwina 1
#> 3 Anthony Kate 2
#> 4 Benedicte Anthony 4
#> 5 Edwina Kate 2
#> 6 Kate Anthony 1
#> 7 Kate Edwina 4
(sub_with_numbers=tibble::tribble(
~source, ~target, ~weight,
1, 2, 3,
1, 3, 1,
1, 4, 2,
2, 1, 4,
3, 4, 2,
4, 1, 1,
4, 3, 4
))
#> # A tibble: 7 × 3
#> source target weight
#> <dbl> <dbl> <dbl>
#> 1 1 2 3
#> 2 1 3 1
#> 3 1 4 2
#> 4 2 1 4
#> 5 3 4 2
#> 6 4 1 1
#> 7 4 3 4
# network --------------------------------------------------------------------
library(igraph)
#>
#> Attachement du package : 'igraph'
#> Les objets suivants sont masqués depuis 'package:stats':
#>
#> decompose, spectrum
#> L'objet suivant est masqué depuis 'package:base':
#>
#> union
netsub <- graph.data.frame(sub,
directed=T)
E(netsub)$width <- sub$weight
plot(netsub)
# betweeness with igraph --------------------------------------------------
betweenness(netsub)
#> Anthony Benedicte Edwina Kate
#> 5 0 0 2
betweenness(netsub,directed=TRUE,weights=E(netsub)$weight)
#> Anthony Benedicte Edwina Kate
#> 5 0 0 2
Created on 2023-10-16 with reprex v2.0.2