Class UndirectedModularityMeasurer<V,​E>

  • Type Parameters:
    V - the vertex type
    E - 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.

    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INVALID_PARTITION_OF_VERTICES

        private static final java.lang.String INVALID_PARTITION_OF_VERTICES
        See Also:
        Constant Field Values
      • graph

        private final Graph<V,​E> graph
      • m

        private double m
      • degrees

        private java.util.Map<V,​java.lang.Double> degrees
    • Constructor Detail

      • UndirectedModularityMeasurer

        public UndirectedModularityMeasurer​(Graph<V,​E> graph)
        Construct a new measurer
        Parameters:
        graph - the input graph
    • 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
      • precomputeDegrees

        private void precomputeDegrees​(Graph<V,​E> graph)
        Pre-compute vertex (weighted) degrees.
        Parameters:
        graph - the input graph