r - How to compare communities in two consecutive graphs -


i have same graph represented @ 2 different times, g.t0 , g.t1. g.t1 differs g.t0 having 1 additional edge maintains same vertices.

i want compare communities in g.t0 , g.t1, is, test whether vertices moved different community t0 t1. tried following

library(igraph)  m <- matrix(c(0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0),nrow=4,ncol=4)  g.t0 <- graph.adjacency(m) memb.t0 <- membership(edge.betweenness.community(g.t0)) v(g.t0) # vertex sequence: #   [1] 1 2 3 4 memb.t0 # [1] 1 2 2 3  g.t1 <- add.edges(g.t0,c(1,2)) memb.t1 <- membership(edge.betweenness.community(g.t1)) v(g.t1) # vertex sequence: #   [1] 1 2 3 4 memb.t1 # [1] 1 1 1 2 

but of course problem indexing of communities start 1. in example seems vertices have moved different community, intuitive reading vertex 1 changed community, moving 2 , 3.

how approach problem of counting number of vertices changed communities t0 t1?

actually not easy question. in general need match communities in 2 graphs, using rule or criteria matching optimizes. can have different number of communities, matching not bijective.

there several methods , quantities proposed problem, bunch implemented in igraph, see http://igraph.org/r/doc/compare.communities.html.

compare.communities(memb.t1, memb.t0, method="vi") # [1] 0.4773856 compare.communities(memb.t1, memb.t0, method="nmi") # [1] 0.7020169 compare.communities(memb.t1, memb.t0, method="rand") # [1] 0.6666667 

see references in igraph manual details methods.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -