TP 3 : community detection algorithms
Rushed Kanawati December 12, 2019
Community detection in igraph
igraphoffers a bunch of different community detection algorithms. Examples are: edge.betweenness.community, multilevel.community, walktrap.communityandinfomap.community. All of these methods re-
turn acommunitiesobject. Metrics on community structure can be applied on this obtained object.
An exemple code is the following:
k a r a t e <− r e a d . graph ( ” k a r a t e . gml ” , f o r m a t=”gml ” ) wc <− m u l t i l e v e l . community ( k a r a t e )
The modularity of the found community structure is computed by the following function : m o d u l a r i t y ( wc )
[ 1 ] 0 . 4 1 8 8 0 3 4
The community membership vector of all nodes in the network is obtained as follows:
> membership ( com )
[ 1 ] 2 2 2 2 1 1 1 2 4 2 1 2 2 2 4 4 1 2 4 2 4 2 4 3 3 3 4 3 3 4 4 3 4 4 The quality of obtained community structure compared to he ground-truth community structure (given by the value attribute of each node) is then obtained as :
> compare ( com ,V( k a r a t e ) $ v a l u e , method=”nmi ” ) [ 1 ] 0 . 5 8 6 6 3 4 8
igraphoffers also some basic communities plotting primitives :
> p l o t ( com , k a r a t e )
this plots the network shown on figure 1
>p l o t ( k a r a t e , v e r t e x . c o l o r=membership ( com ) ) This plots the network shown on figure 2
1
Figure 1: Community structure using Louvain algorithm on the Karate network
Figure 2: Community structure using Louvain algorithm on the Karate network
Exercices
1 Download the following filesdolphins.gml, football.gml, karate.gmlfromhttp://lipn.
fr/~kanawati/ars. In these graphs the ground-truth community of each node is given by the attribut value. For each of these graphs apply apply different community detection algorithms and compare the results in function of similarity with the ground-truth commu- nity structure. Compare also the obtained community structures obtained by the different algorithms. Conclusions.
2 Download the following filewikipedia.gml fromhttp://lipn.fr/~kanawati/ars. This is snap of the wikipedia network. Nodes have alabelattribute that gives the title of the wikipedia page. Apply different community detection algorithms on this network and evaluate the outcome using the label attribute.
2