---
title: Fair Modularity Optimization (FairFN)
url: https://www.emergentmind.com/topics/fair-modularity-optimization-fairfn
type: topic
---

# Fair Modularity Optimization (FairFN)

Fair Modularity Optimization (FairFN) is a principled approach to community partitioning in graphs that enforces statistical fairness for protected demographic groups while optimizing structural quality as measured by modularity. Unlike traditional modularity maximization, which may produce highly unrepresentative or biased clusters regarding the distribution of protected groups, FairFN operationalizes proportional group representation through a fairness-modularity metric, yielding partitions that are provably fair and competitive in structural quality. The framework encompasses both bi-objective formulations and algorithmic realizations such as Fair Fast Newman (FairFN) and multilevel scalable solvers exemplified by MOUFLON, enabling practical application to synthetic and real-world networks with challenging size and balance properties [2505.22684], [2510.12348].

## 1. Fairness–Modularity Metric: Theoretical Foundations

At the core of FairFN is the fairness–modularity metric, $Q^P$, defined on a network $G=(V,E)$ with $n=|V|$ nodes and $r$ disjoint protected groups $P_1,\ldots,P_r$ partitioning $V$. Building on the conventional Newman–Girvan modularity, FairFN introduces a protected-group network $G^P$, whose adjacency matrix $D$ is block-diagonal, with blocks of all ones corresponding to each $P_w$. The degree vector $K^P$ and $m^P=\frac12\sum_{w=1}^r |P_w|^2$ characterize $G^P$.

Given a partition encoded by $S\in\{0,1\}^{n\times k}$, the fairness–modularity is:
\[
Q^P = \frac{1}{2m^P}\,\mathrm{Tr}(S^T B^P S)
\]
where $B^P = D - \frac{1}{2m^P} K^P (K^P)^T$. Expanding,
\[
Q^P = \frac{1}{2m^P} \sum_{u=1}^k \sum_{w=1}^r |C_u \cap P_w|^2
- \frac{1}{(2m^P)^2} \sum_{u=1}^k \left( \sum_{w=1}^r |C_u \cap P_w| |P_w| \right)^2
\]
with $|C_u \cap P_w|$ counting nodes from $P_w$ assigned to community $C_u$.

A central property (Fairness Characterization Theorem) is:
\[
Q^P \geq 0 \text{ always, and } Q^P = 0 \iff
\frac{|C_u \cap P_w|}{|C_u|} = \frac{|P_w|}{n},\ \forall u, w,
\]
i.e., exactly when each community represents protected groups in proportion to their global prevalence. Thus, minimizing $Q^P$ enforces statistical parity. The plausible implication is that $Q^P$ provides both a penalty and a certificate for group-proportional clustering.

## 2. Optimization Framework: Bi-Objective and Scalarized Formulations

Community detection with fairness constraints under FairFN becomes an inherently bi-objective problem:
- maximize classic modularity $Q$ for structural quality,
- minimize $Q^P$ for fairness.

Formally, this yields:
\[
\max_{S}\ Q(S) \quad \mathrm{subject~to}~ Q^P(S) \leq \epsilon
\]
or, scalarized,
\[
\max_S Q(S) - \lambda Q^P(S),\quad \lambda \geq 0
\]
In this setup, $\lambda$ or $\epsilon$ controls the trade-off between fairness and structure. Both $Q$ and $Q^P$ are combinatorial and make optimal partitioning NP-hard. Greedy modularity-based methods are therefore adapted, augmented with fairness-modularity compliance or penalty checks at each iterative step [2505.22684], [2510.12348].

## 3. Algorithmic Realizations

### Fair Fast Newman (FairFN)

FairFN modifies the classic Fast Newman (FN) greedy merging procedure:
- Each node starts as its own community.
- For each pair $(i,j)$, compute modularity increments $\Delta Q_{ij}$ and fairness–modularity increments $\Delta Q^P_{ij}$.
- At each step, among pairs with $\Delta Q_{ij} > -\alpha/(2m)$ and $\Delta Q^P_{ij} < 0$, merge the pair with maximum $\Delta Q_{ij}$.
- Stop when no such merge remains.

This one-line modification—filtering merges through $\Delta Q^P_{ij} < 0$—enforces non-increasing unfairness. The algorithm exhibits complexity $O(n(m+n))$ in time and $O(n^2)$ space per run, with practical data structure optimizations reducing overhead [2505.22684].

### MOUFLON: Scalable Louvain-Style Optimization

MOUFLON implements FairFN in a multilevel Louvain-style framework for large-scale graphs and multi-group settings [2510.12348]. The method proceeds in repeated two-phase passes per graph level:
- Phase 1: Pure modularity maximization (local node moves).
- Phase 2: Joint optimization of $J_\alpha(P) = \alpha Q(P) + (1-\alpha) F(P)$, where $F(P)$ is a proportional-balance fairness metric (responsive to multi-group and imbalance).
- Super-node aggregation and reiteration on the induced graph.
Termination occurs when $J_\alpha$ gain falls below threshold $\theta$.

MOUFLON achieves running time $O(m\log n)$ empirically (for up to $10^6$ nodes), with $O(Kn)$ space for maintaining group counts.

## 4. Evaluation: Datasets, Metrics, and Comparative Performance

Experiments in [2505.22684] and [2510.12348] cover synthetic (LFR, ER, Gaussian blobs, rewired cliques) and real tabular and network datasets (e.g., Adult, Bank, Census1990, Creditcard, Facebook, Deezer, Twitch, Pokec). Protected attributes span gender, marital status, age, etc., with controlled balance or severe group size skew.

Metrics include:
- Modularity $Q$ (structural quality; higher is better),
- Fairness–modularity $Q^P$ (lower is better),
- Fairness ratio FR = $\min_u \min_w \big\{ r(u,w)/r(w), r(w)/r(u,w) \big\} \in [0,1]$,
- Average Wasserstein distance (AWD) between local and global group distributions,
- Proportional-balance metric $F(P)$ (for multi-group fairness),
- NMI to ground-truth (in synthetic settings).

Key findings:
- FairFN rapidly drives $Q^P \to 0$, achieving FR$\to 1$ and AWD$\to 0$ while incurring only a small decrease in modularity $Q$ relative to FN.
- On highly imbalanced synthetic settings, FairFN attains FR$\approx 0.99$ and AWD$\approx 0.002$; state-of-the-art competitors plateau at FR$=0.6$–$0.9$, AWD$\approx 0.01$.
- On real-world datasets, FairFN consistently yields near-optimal fairness (FR$\to 1$), low $Q^P$, and modularity close to or exceeding that of unconstrained methods.
- MOUFLON produces a continuous Pareto front by tuning trade-off parameter $\alpha$, achieving scalable (up to over $1$M nodes) and flexible performance; for mid-range $\alpha$, modularity remains $\geq 0.7$ and proportional-fairness $F_\mathrm{prop}\geq 0.9$.

A comparative summary is as follows:

| Method      | Fairness Constraint | Modularity $Q$ | Fairness (FR/$Q^P$/F) | Scalability       |
|:------------|:-------------------|:--------------:|:---------------------:|:-----------------:|
| FN          | None               | High           | Low                   | $O(n(m+n))$       |
| FairFN      | $Q^P$               | High           | High (provable)       | $O(n(m+n))$       |
| MOUFLON     | $F_\mathrm{prop}$   | Flexible       | Flexible/High         | $O(m\log n)$      |

## 5. Practical Insights, Hyperparameter Choices, and Trade-Offs

In both FairFN and MOUFLON, fairness–modularity and proportional-fairness metrics provide tunable levers. The key hyperparameter is:
- $\alpha$ (in merge thresholding or Louvain-like passes): small $\alpha$ enforces strict fairness ($Q^P \to 0$), larger $\alpha$ relaxes fairness in exchange for possible modularity gains.
Empirical guidance suggests setting $\alpha$ just above $2m \max_{ij} \Delta Q_{ij}$ for convergence; in MOUFLON, $\alpha \in [0.4, 0.7]$ delivers stable results, while mission-critical fairness may require $\alpha \leq 0.3$.

For multi-group and highly imbalanced data, proportional-balance $F_\mathrm{prop}$ should always be used; naive balance metrics can mask true disparities and produce degenerate solutions.

## 6. Limitations and Future Directions

The FairFN framework offers a suite of advantages but remains subject to scalability and theoretical challenges:
- The $O(n(m+n))$ complexity of classic FairFN is nontrivial for $n \gg 10^5$; however, the fairness-filter concept integrates with scalable algorithms like Louvain and CNM.
- Both FairFN and MOUFLON rely on greedy merging; local maxima may require global moves or refinement such as Kernighan–Lin.
- Current fairness metrics assume proportional representation and single sensitive attributes; extensions to overlapping, dynamic communities, and intersectional fairness are open.
- Scaling beyond millions of edges may require low-level or external-memory implementations.

A plausible implication is that continued development will focus on integrating fairness guarantees into high-throughput modularity frameworks, exploring richer notions of null models, and addressing intersectional and temporal fairness in evolving networks [2505.22684], [2510.12348].

Source: https://www.emergentmind.com/topics/fair-modularity-optimization-fairfn