- java.lang.Object
-
- org.jgrapht.alg.clustering.UndirectedModularityMeasurer<V,E>
-
- Type Parameters:
V
- the vertex typeE
- the edge type
public class UndirectedModularityMeasurer<V,E> extends java.lang.Object
A modularity measurer.This is a utility class which computes the modularity function. It takes as input a list of vertex classes $C$ and a graph $G$ and calculates: $Q = \frac{1}{2m} \sum_{ij} \left( A_{ij} - \frac{k_i k_j}{2m} \right) \delta(C_i, C_j)$. Here $m$ is the total number of edges and $k_i$ is the degree of vertex $i$. $A_{ij}$ is either $1$ or $0$ depending on whether edge $(i,j)$ belongs to the graph and $\delta(C_i, C_j)$ is 1 if vertices $i$ and $j$ belong to the same class, $0$ otherwise.
-
-
Constructor Summary
Constructors Constructor Description UndirectedModularityMeasurer(Graph<V,E> graph)
Construct a new measurer
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
modularity(java.util.List<java.util.Set<V>> partitions)
Compute the modularity of a vertex partition.private void
precomputeDegrees(Graph<V,E> graph)
Pre-compute vertex (weighted) degrees.
-
-
-
Field Detail
-
INVALID_PARTITION_OF_VERTICES
private static final java.lang.String INVALID_PARTITION_OF_VERTICES
- See Also:
- Constant Field Values
-
m
private double m
-
degrees
private java.util.Map<V,java.lang.Double> degrees
-
-
Method Detail
-
modularity
public double modularity(java.util.List<java.util.Set<V>> partitions)
Compute the modularity of a vertex partition.- Parameters:
partitions
- the partitions- Returns:
- the modularity
-
-