NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Bounded Graph Clustering with Graph Neural Networks

Kibidi Neocosmos, Diego Baptista, Nicole LudwigarXiv 2025 · OpenReview

TL;DR

This paper introduces a novel constraint for graph neural networks (GNNs) that allows users to specify a desired range for the number of communities detected, overcoming a key limitation of existing GNN-based community detection methods. This flexible approach ensures that the number of discovered communities falls within user-defined bounds, offering more control and reliability than previous techniques.

What Problem Does This Paper Address?

Community detection, the task of identifying meaningful groups of nodes in a network, is a crucial problem in network analysis. While many traditional algorithms require users to pre-specify the number of communities, graph neural networks (GNNs) designed for this task often fail to adhere to this specification. Even when a target number of clusters is provided, standard GNNs tend to output a number of communities that is less than or equal to the specified value, and not necessarily the exact number. This lack of precise control makes it difficult to tailor GNNs for applications where a specific community count or range is critical. The paper aims to bridge this gap by enabling GNNs to reliably output a number of communities within a user-defined range, or even an exact number if desired.

Methods

The core contribution of this work is a new constraint that is incorporated into the loss function of a GNN used for community detection. This constraint, when combined with the upper bound naturally provided by the GNN's architecture, creates a flexible range for the number of output communities. The authors propose a method that normalizes the cluster assignment matrix and then uses this normalized matrix to enforce a lower bound on the number of communities. This constraint can be used to specify either an exact number of communities (by setting the lower and upper bounds to be equal) or a range. To further improve the quality of the detected communities, the authors also incorporate a regularization term that encourages balanced clusters (i.e., communities of similar size), drawing inspiration from existing work. The combined loss function thus includes the community quality measure (modularity), the proposed constraint, and the balance regularization term.

Datasets

The authors evaluated their proposed method on both synthetic and real-world datasets.

  • Synthetic Datasets: Generated using the stochastic block model (SBM), varying network size, density, and the number of ground-truth communities.
  • Real-world Datasets:
    • Cora, Citeseer, PubMed: Citation networks where nodes are publications and communities are topic labels.
  • Actor: A co-occurrence network where nodes are actors and communities correspond to actor or role categories.

Key Insights and Ideas

  • GNNs Struggle with Exact Community Counts: A fundamental observation is that standard GNNs for community detection, even when given a target number of clusters, often fail to return that exact number, typically producing fewer.
  • Constraint for Bounded Output: The proposed constraint effectively forces the GNN to output a number of communities within a user-defined range, offering a novel level of control.
  • Exact Number Achievable: By setting the lower and upper bounds of the range to be equal, the GNN can be reliably made to output a specific, exact number of communities.
  • Synergy of Constraint and Regularization: Combining the constraint with a balance regularization term leads to better community detection results, as the regularization encourages more nodes per community, which is beneficial for modularity-based objectives.
  • Counteracting Modularity's Resolution Limit: The constraint can indirectly help mitigate the resolution limit of modularity, a phenomenon where modularity-based methods struggle to detect small communities. By enforcing a minimum number of communities, the constraint can push the model to identify more, even if it slightly compromises the modularity score.

Key Results

  • Constraint Enforcement: The proposed constraint was successfully enforced across all tested synthetic and real-world datasets, ensuring the output number of communities fell within the specified bounds.
  • Improved Community Detection Quality: Models incorporating the constraint, especially when combined with balance regularization, showed higher Adjusted Rand Index (ARI) scores on synthetic data compared to models without the constraint, indicating more meaningful community assignments.
  • Comparable Runtime: The addition of the constraint and regularization terms had a negligible impact on the runtime of the GNN models, suggesting practical applicability.
  • Robustness to Network Properties: The constraint's effectiveness was demonstrated across varying network densities, sizes, and numbers of true communities in synthetic experiments.

Limitations and Future Work

  • Synthetic Data Assumption: The synthetic networks used in experiments had strong community structures. A limitation is that the performance degradation on networks with weaker community structures remains to be systematically explored.
  • Search for Optimal Number: The paper suggests that the introduced constraint opens up possibilities for searching for an optimal number of communities by progressively tightening the range and selecting the output with the highest modularity. This is identified as a promising future research direction.
  • Hyperparameter Tuning: While the authors suggest default values for hyperparameters (μ=λ=1), further investigation into optimal tuning strategies for different datasets and scenarios could be beneficial.
  • Differentiability of Constraint: The paper discusses the differentiability of the constraint, noting that while it is differentiable, only a few entries of the cluster assignment matrix influence the derivative. This aspect might warrant further theoretical exploration.

Summary updated

Abstract

In community detection, many methods require the user to specify the number of clusters in advance since an exhaustive search over all possible values is computationally infeasible. While some classical algorithms can infer this number directly from the data, this is typically not the case for graph neural networks (GNNs): even when a desired number of clusters is specified, standard GNN-based methods often fail to return the exact number due to the way they are designed. In this work, we address this limitation by introducing a flexible and principled way to control the number of communities discovered by GNNs. Rather than assuming the true number of clusters is known, we propose a framework that allows the user to specify a plausible range and enforce these bounds during training. However, if the user wants an exact number of clusters, it may also be specified and reliably returned.
BibTeX
@misc{neocosmos2025bounded,
  author = {Kibidi Neocosmos and Diego Baptista and Nicole Ludwig},
  title = {{Bounded Graph Clustering with Graph Neural Networks}},
  year = {2025},
  eprint = {2512.05623},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.05623},
}
Figure