I have a question whether order of edges in graph should matter or not?
It seems that betweenness function produces slightly different results for different orderings of input file.
input file : http://preview.tinyurl.com/p9vlxnc
#1st run, with unordered edges
edges <- read.csv("example.csv", col.names=c("src", "dest"), colClasses = "character")
social.graph <- graph.edgelist(as.matrix(edges), directed=T)
social.graph <- graph.adjacency(get.adjacency(social.graph), weighted=TRUE)
E(social.graph)$weight <- 1 / E(social.graph)$weight
set.seed(1)
between1 <- betweenness(social.graph)
#2nd run, with now ordered edges
edges <- edges[order(edges[,1], edges[,2]),]
social.graph <- graph.edgelist(as.matrix(edges), directed=T)
social.graph <- graph.adjacency(get.adjacency(social.graph), weighted=TRUE)
E(social.graph)$weight <- 1 / E(social.graph)$weight
set.seed(1)
between2 <- betweenness(social.graph)
print(merge(data.frame(between1=between1, names=names(between1)),
data.frame(between2=between2, names=names(between2))))
the results are slightly different for two nodes 1341 and 1352
names between1 between2
1 1284 0.5833333 0.5833333
2 1304 0.0000000 0.0000000
3 1320 21.7500000 21.7500000
4 1336 1.7500000 1.7500000
5 1341 15.0833333 14.0833333
6 1345 2.0000000 2.0000000
7 1350 0.7500000 0.7500000
8 1352 74.2500000 75.2500000
9 1356 0.0000000 0.0000000
10 1358 0.0000000 0.0000000
11 1387 1.8333333 1.8333333
12 1398 16.0000000 16.0000000
13 1405 0.5833333 0.5833333
14 1439 1.0000000 1.0000000
15 1960 34.0000000 34.0000000
16 3918 0.0000000 0.0000000
this is very weird as the adjacency matrices are the same (only have different order of columns/rows). Is this a bug or betweenness does depends somehow on the ordering of the edges?