gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
303 stars 99 forks source link

betweenness centrality #1949

Closed benoitgaudou closed 8 years ago

benoitgaudou commented 8 years ago

Steps to reproduce

  1. Run the following model that computes betweenness centrality on a line network:

global { graph g <- graph([]);

init { 
    create people number:5{
        add node(self) to: g;
    }
}

reflex toto{
    add edge(people(0)::people(1)) to:g;
    add edge(people(1)::people(2)) to:g;
    add edge(people(2)::people(3)) to:g;
    add edge(people(3)::people(4)) to:g;
    map b <- betweenness_centrality(g);

    write b;
}

}

species people{ }

Expected behavior

R software provides for an equivalent undirected network the result [0 2 2 0](or for directed network [0 4 4 0]). ( library(igraph) mg <- matrix(c(c(0,1,0,0),c(1,0,1,0),c(0,1,0,1),c(0,0,1,0)), ncol=4, byrow=T) ' g1 <- graph_from_adjacency_matrix( mg ) g1 <- graph_from_adjacency_matrix( mg, mode = "undirected") g1 betweenness(g1)) )

Actual behavior

I get following result: map([people(1)::7.0,people(2)::10.0,people(3)::9.0,people(4)::4.0]) (even for directed or undirected network)

System and version

GAMA Git MACOsX

ptaillandier commented 8 years ago

It is now fixed. Note that you have a small error in your example: in the GAMA model, you have 5 nodes, and only 4 in the R script. If you remove the last node in the GAMA model, you will get the same result as with R.