View source: R/graph_modul_compar.R
graph_modul_compar  R Documentation 
The function computes the Adjusted Rand Index (ARI) to compare two graphs' partitions into modules or clusters more generally. Both graphs must have the same number of nodes, but not necessarily the same number of links. They must also have the same node names and in the same order.
graph_modul_compar( x, y, mode = "graph", nb_modul = NULL, algo = "fast_greedy", node_inter = "distance", data = NULL )
x 
The first graph object

y 
The second graph object
Same classes possible as for 
mode 
A character string indicating whether x and y are igraph objects,
vectors or columns from a data.frame. 
nb_modul 
(if x and y are igraph objects) A numeric or integer value or a numeric vector with 2 elements indicating the number of modules to create in both graphs.

algo 
(if x and y are igraph objects) A character string indicating the algorithm used to create the modules with igraph.

node_inter 
(optional, if x and y are igraph objects, default is 'none') A character string indicating whether the links of the graph are weighted by distances or by similarity indices. It is only used to compute the modularity index. It can be:
Two different weightings can be used to create the modules of the two graphs.

data 
(if x and y are columns from a data.frame) An object of class data.frame with at least two columns and as many rows as there are nodes in the graphs compared. The columns indicate the modules of each node in 2 different classifications. 
This index takes values between 1 and 1. It measures how often
pairs of nodes pertaining to the same module in one graph also pertain to
the same module in the other graph.
Therefore, large values indicate that both partitions are similar.
The Rand Index can be defined as the frequency of agreement between two
classifications into discrete classes. It is the number of times a pair of
elements are classified into the same class or in two different classes
in both compared classifications, divided by the total number of possible
pairs of elements. The Rand Index is between 0 and 1 but its maximum value
depends on the number of elements. Thus, another 'adjusted' index was
created, the Adjusted Rand Index. According to the Hubert et
Arabie's formula, the ARI is computed as follows:
ARI=\frac{Index  Expected index}{Maximum index  Expected index}
where the values of Index, Expected index and Maximum index are computed
from a contingency table.
This function uses adjustedRandIndex
from package mclust which
applies the Hubert and Arabie's formula for the ARI.
This function works for undirected graphs only.
The value of the ARI
P. Savary
dyer2004populationgraph4lg \insertRefhubert1985comparinggraph4lg \insertRefclauset2004findinggraph4lg \insertRefblondel2008fastgraph4lg \insertRefbrandes2008modularitygraph4lg \insertRefpons2006computinggraph4lg
data(data_ex_genind) data(pts_pop_ex) mat_dist < suppressWarnings(graph4lg::mat_geo_dist(data=pts_pop_ex, ID = "ID", x = "x", y = "y")) mat_dist < mat_dist[order(as.character(row.names(mat_dist))), order(as.character(colnames(mat_dist)))] graph_obs < gen_graph_thr(mat_w = mat_dist, mat_thr = mat_dist, thr = 24000, mode = "larger") mat_gen < mat_gen_dist(x = data_ex_genind, dist = "DPS") graph_pred < gen_graph_topo(mat_w = mat_gen, mat_topo = mat_dist, topo = "gabriel") ARI < graph_modul_compar(x = graph_obs, y = graph_pred)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.