ntmod
Modularity of a partition
ntmod(from, to, memb, w = NULL, nodes = NULL, res = 1)Q = sum over communities of in / 2m - res (tot / 2m)^2, where in is
the weight of edges inside the community (counted from both ends),
tot the summed strength of its nodes and 2m the total strength
(Newman and Girvan 2004), on the undirected, weighted graph. At res = 1 it lies between -1/2 and 1 (proof("ntmod")). NaN for a graph
without edges. Graph rules as in ntdeg().
Parameters
Section titled “Parameters”from, toLabels of the two ends of each edge: vectors of the same length (zero when
nodesgives every node) with no missing values.membThe community of each node: labels, either named by node (every node named once; other names are ignored) or unnamed, one per node in the order the network functions report nodes.
wNULL, or one positive weight per edge (a tie’s strength, such as the number of co-offences).nodesNULL, or every node’s label once: the node order of the results and the way to include isolated nodes.resThe resolution: one number, at least 0.
Returns
Section titled “Returns”The modularity, one number.
References
Section titled “References”Newman, M. E. J. and Girvan, M. (2004). Finding and evaluating community structure in networks. Physical Review E, 69(2), 026113. doi:10.1103/PhysRevE.69.026113
Examples
Section titled “Examples”ntmod(c(1, 1, 2, 4, 4, 5, 3), c(2, 3, 3, 5, 6, 6, 4), memb = c(1, 1, 1, 2, 2, 2))Generated from the R help page: ntmod in the R reference.