modularity {wsyn} | R Documentation |
Modularity of a community structure of a graph
Description
Computes the modularity of partitioning of a graph into sub-graphs. Similar to the
modularity
function in the igraph
package, but allows negative
edge weights.
Usage
modularity(adj, membership, decomp = FALSE)
Arguments
adj |
An adjacency matrix, which should be symmetric with zeros on the diagonal. |
membership |
Vector of length equal to the number of graph nodes (columns/rows
of |
decomp |
Logical. If |
Details
The difference between this function and the function modularity
in the package igraph
is that this function can be used with an adjacency
matrix with negative elements. This is a common case for matrices arrising from a
for correlation matrix or another synchrony matrix. If the matrix is non-negative,
the result of this function should be exactly the same as the result from
modularity
in the igraph
package.
Value
modularity
returns a list containing the following:
totQ |
The total modularity. This is the only output if |
modQ |
The contribution of each module to the total modularity |
nodeQ |
The contribution of each node to the total modularity |
Note
Adapted from code developed by Robert J. Fletcher, Jr.
Author(s)
Jonathan Walter, jonathan.walter@ku.edu; Lei Zhao, lei.zhao@cau.edu.cn; Daniel Reuman, reuman@ku.edu
References
Fletcher Jr., R.J., et al. (2013) Network modularity reveals critical scales for connectivity in ecology and evolution. Nature Communications. doi: 10.1038//ncomms3572.
Gomez S., Jensen P. & Arenas A. (2009). Analysis of community structure in networks of correlated data. Phys Rev E, 80, 016114.
Newman M.E. (2006). Finding community structure in networks using the eigenvectors of matrices. Phys Rev E, 74, 036104.
See Also
clust
, cluseigen
, browseVignettes("wsyn")
Examples
adj<-matrix(0, 10, 10) # create a fake adjacency matrix
adj[lower.tri(adj)]<-runif(10*9/2, -1, 1)
adj<-adj+t(adj)
colnames(adj)<-letters[1:10]
m<-cluseigen(adj)
z<-modularity(adj, m[[length(m)]], decomp=TRUE)