Skip to Content
InformationInformation
  • Article
  • Open Access

16 April 2026

23 Pages

Edge-Centric Federated Subgraph Isomorphism Counting via Residual Graph Neural Networks

,
and
School of Computer Science and Technology, University of Science and Technology of China, Hefei 230027, China
*
Author to whom correspondence should be addressed.

Abstract

Subgraph isomorphism counting is a fundamental yet computationally challenging task in graph analysis, with broad applications in bioinformatics and social network mining. With the tightening of data privacy regulations and the emergence of data silos, traditional centralized Graph Neural Network (GNN) approaches face significant deployment hurdles. Existing federated subgraph counting methods are primarily designed for database federation scenarios, focusing on exact queries and the privacy and security concerns of databases. However, this rigid focus on exactness and heavy cryptographic security severely limits their scalability and generalizability to complex, arbitrary query patterns. To bridge this gap, we propose a general Federated Edge-Centric Framework for Subgraph Isomorphism Counting (FedCount), shifting the paradigm from exact querying on federated databases to neural approximate counting under federated architectures. Rather than relying on heavy cryptographic techniques, we exclusively leverage the inherent structural isolation of federated learning as a lightweight empirical privacy measure. While this framework does not theoretically defend against advanced gradient-based inference attacks, it successfully prevents the direct leakage of raw graph topology and node features, achieving high-precision approximate counting without the prohibitive cryptographic overheads. Specifically, we introduce two key technical innovations to enhance local counting capability: (1) we integrate a provable edge encoding scheme into the interaction-based GNN architecture, explicitly modeling edge-to-edge interactions to break the expressiveness bottleneck of standard message passing; (2) we design a Residual Edge-Centric Readout mechanism that mitigates the gradient vanishing problem, enabling the effective training of deeper networks to capture high-order topological dependencies. Extensive experiments on multiple benchmark datasets demonstrate that our framework significantly outperforms existing distributed enumeration baselines in terms of generalization and efficiency, approaching the performance of centralized state-of-the-art models.

1. Introduction

Subgraph isomorphism counting [1], which aims to determine the occurrence frequency of a specific query pattern within a target graph, serves as a fundamental primitive in graph analysis with diverse applications. These range from discovering interaction motifs in social networks [2,3] to analyzing protein interaction structures in bioinformatics [4] and identifying specific functional motifs within brain connectivity networks in neuroscience [5]. Despite its significance, this task is computationally intractable; the underlying decision problem is known to be NP-Complete [6], rendering the counting variant #P-Complete. Consequently, traditional combinatorial algorithms [7,8] inherently suffer from exponential time complexity, making them prohibitive for large-scale graph data. To address this efficiency bottleneck, recent advancements have shifted towards data-driven approaches based on Graph Neural Networks (GNNs) [9,10]. By reformulating counting as a “learning-to-match” problem, these neural models have achieved remarkable success, offering superior scalability and robust generalization to unseen graphs compared to traditional heuristics.
However, the practical deployment of these centralized neural counting models faces significant hurdles in real-world scenarios. Driven by increasingly stringent data privacy regulations (e.g., HIPAA and GDPR) and institutional barriers, graph data is naturally distributed across isolated data silos. For instance, counting specific brain connectivity motifs associated with neurodegenerative disorders (e.g., Alzheimer’s disease) often requires aggregating patient data from multiple medical institutions, yet sharing raw brain graph data is strictly prohibited due to ethical and legal constraints. Federated learning (FL) [11] has emerged as the *de facto* paradigm to resolve this dilemma, enabling collaborative model training without exposing raw data. While federated graph learning (FGL) [12] has witnessed a surge in research, existing works predominantly focus on representation learning tasks such as node classification or link prediction. In stark contrast, federated subgraph isomorphism counting, despite being a core primitive of graph analysis, remains a largely unexplored frontier.
To address these privacy challenges, existing efforts have primarily resorted to database querying or cryptographic techniques to achieve exact counting in federated settings. For instance, Yuan et al. [13] designed a framework for subgraph matching over isolated graph databases, focusing on query decomposition and exact result assembly. For specific motifs like triangles, MAGO [3] leverages homomorphic encryption to ensure malicious security, while CARGO [14] and Sectric [15] combine Differential Privacy with Secure Multi-Party Computation. While these methods offer theoretical security guarantees, they suffer from fundamental utility bottlenecks in practice. First, limited applicability: most algorithms are hard-coded for simple, fixed motifs (e.g., triangles or cliques), lacking the flexibility to generalize to arbitrary, complex query patterns. Second, the accuracy–efficiency trade-off: noise injected by Differential Privacy significantly degrades the precision of regression-based counting tasks, while homomorphic encryption incurs prohibitive computational overheads. Consequently, there is an urgent need for a new federated counting paradigm that balances generalizability, computational efficiency, and privacy.
However, realizing such a general neural counting framework is non-trivial. Simply deploying existing GNN-based counting models (e.g., Count-GNN [10]) within a federated architecture faces two critical architectural hurdles. First, the expressiveness bottleneck of local models. Standard GNNs are theoretically bounded by the 1-Weisfeiler-Lehman (1-WL) test [16], failing to distinguish certain fundamental structural patterns. In a federated setting where local data is limited and heterogeneous, this lack of structural discriminability is amplified: if local models cannot generate high-quality structural embeddings, the aggregated global model inevitably converges to a suboptimal state. Second, the instability of training deep architectures. Capturing complex, high-order subgraph patterns requires stacking multiple network layers to achieve a sufficient receptive field. Yet, in federated learning, the naive parameter averaging strategy (e.g., FedAvg) often exacerbates the gradient vanishing problem in deep GNNs, leading to convergence failure or poor generalization. Consequently, empowering local models with stronger structural awareness and training stability is pivotal for achieving high-precision federated counting.
To surmount these hurdles, we propose FedCount, a general Federated Edge-Centric Framework for Subgraph Isomorphism Counting. Instead of devising intricate server-side aggregation protocols, our approach prioritizes fortifying the local learning backbone of clients to ensure that transmitted updates carry high-fidelity structural information. Specifically, we re-engineer the architecture of the local counting model: (1) we integrate the provable edge encoding scheme from ES-GNN [17] into the interaction-based GNN architecture. By explicitly modeling edge-to-edge interactions, this mechanism breaks the 1-WL expressiveness barrier, enabling local models to capture precise structural semantics; (2) we design a Residual Edge-Centric Readout mechanism. By introducing residual connections into the readout phase, we create direct pathways for gradient flow, effectively mitigating the vanishing gradient problem and ensuring robust convergence of deep networks even under the standard FedAvg protocol. Crucially, FedCount relies solely on the inherent structural isolation of the federated architecture to prevent the direct leakage of raw graph topology and node features. While this lightweight mechanism explicitly trades formal theoretical guarantees against advanced inference attacks (e.g., gradient leakage) for computational efficiency, it provides a practical privacy-utility balance, achieving high-precision counting without the severe utility loss associated with heavy cryptographic noise.
In summary, our main contributions are as follows:
  • A General Federated Neural Counting Paradigm: We propose FedCount, the first general federated learning framework that shifts the subgraph counting task from the traditional “database-oriented exact querying” paradigm to a “neural-based approximate counting” paradigm. It enables efficient counting of arbitrary complex patterns while preventing the direct leakage of raw graph data through the structural isolation of the federated architecture.
  • A Provably Expressive Federated Backbone: To address the expressiveness bottleneck and training instability of local models in federated settings, we innovatively integrate a provable edge encoding scheme with a Residual Edge-Centric Readout mechanism. This design theoretically breaks the 1-WL barrier and effectively mitigates the gradient vanishing problem in deep GNNs.
  • Superior Generalization and Efficiency: Extensive experiments on multiple benchmark datasets demonstrate that FedCount significantly outperforms existing distributed enumeration baselines in terms of counting precision and generalization. It approaches the performance of centralized state-of-the-art (SOTA) models while maintaining low communication and computational overheads.

2. Related Work

This section details the evolution of subgraph counting methods from traditional combinatorial algorithms to modern neural models. It also outlines the landscape of federated graph learning, differentiating general representation learning from the specific task of federated subgraph counting.

2.1. Subgraph Isomorphism

Subgraph isomorphism counting, defined as determining the frequency of a query graph’s occurrences within a larger target graph, is a fundamental problem in graph analysis. Cook [6] proved that the subgraph isomorphism decision problem is NP-Complete. Consequently, the counting variant belongs to the #P-Complete complexity class, implying that the computational cost grows exponentially with the size of the query pattern and the target graph, posing significant algorithmic challenges.
To tackle this combinatorial explosion, early research focused on developing exact algorithms based on search space pruning. Ullmann [7] proposed the foundational algorithm employing a backtracking strategy, which recursively explores the state space while pruning branches that violate topological constraints. However, its factorial time complexity renders it intractable for large-scale graphs. To accelerate the matching process for complex queries, TurboISO [8] introduced the concept of neighborhood signatures to aggressively filter out unpromising candidate regions before matching. Building on this, Han et al. [18] harmonized dynamic programming with an adaptive matching order to minimize intermediate results. To avoid redundant computations across similar queries, Ribeiro et al. [19,20] developed G-Tries, a specialized prefix tree data structure that stores a collection of subgraphs. By sharing common substructures in the tree, G-Tries significantly accelerate network motif discovery. For the specific task of counting small graphlets (e.g., 3–5 nodes), Pinar et al. [21] and Pashanasangi et al. [22] leveraged vertex orbits and graph automorphism symmetry. By computing orbit relationships, these methods infer counts from a system of linear equations, drastically reducing the number of explicit isomorphism checks required. In the era of big data, single-machine algorithms face memory and runtime bottlenecks. Similarly, [23] uses the orbits of subgraphs to solve the problem, and designs a distributed system for counting arbitrary k-node pattern graphs. Afrati et al. [24] designed a multi-round MapReduce framework to decompose large graphs into manageable partitions for parallel enumeration. Similarly, Lai et al. [25] developed scalable distributed algorithms employing partial join optimization and compression techniques to minimize communication overhead. Despite their exactness, these distributed methods operate under the assumption of full access to the global graph topology, making them unsuitable for federated scenarios where data is siloed and privacy is paramount.
Driven by the need for efficiency and generalization, data-driven approaches based on Graph Neural Networks (GNNs) have emerged as a powerful alternative. Chen et al. [16] provided the first theoretical analysis of the expressive power of GNNs for counting, revealing that standard message passing is bounded by the 1-Weisfeiler-Lehman (1-WL) test and struggles to distinguish certain structural patterns. To transcend these limitations, Liu et al. [9] established the first framework for neural subgraph isomorphism counting, treating it as a regression task over graph embeddings. Zhao et al. [26] introduced a learned sketch-based approach that compresses structural information into compact signatures to efficiently estimate subgraph frequencies. Subsequently, Liu et al. [27] introduced a dual message passing mechanism, which encodes the query and target graphs separately to capture both local and global structural contexts. Wang et al. [28] further innovated by utilizing a Wasserstein discriminator to robustly estimate subgraph frequencies. Addressing the core challenge of accurate isomorphism matching, Yu et al. [10] proposed Count-GNN, which introduced a query–target interaction mechanism. By explicitly modeling the interaction between the query pattern and the target graph at the node level, Count-GNN significantly reduced estimation errors. Liu et al. Furthermore, addressing the challenge of data scarcity, Zhao et al. [29] developed a label-efficient framework optimized for learning subgraph counting queries with limited training samples. Ref. [30] incorporated graph kernel techniques into the neural counting paradigm to theoretically enhance the model’s expressiveness in capturing structural similarities. Fu et al. [31] proposed Desco, a scalable framework that improves generalization capabilities across distinct graph domains by leveraging subgraph decomposition techniques. Most recently, Yan et al. [17] proposed ES-GNN, which integrates a novel edge encoding scheme with provable substructure counting power. This method theoretically guarantees the ability to distinguish complex substructures beyond the 1-WL limit. To extend neural counting to non-deterministic settings, Ban et al. [32] designed a probabilistic framework to estimate motif frequencies in uncertain graphs where edge existence is stochastic. However, despite their advanced architectures, these models are designed for centralized training and cannot be directly deployed in federated environments without violating data privacy regulations.

2.2. Subgraph Federated Learning

Federated learning (FL) [11] has become the de facto standard for collaborative model training without sharing raw data. While federated graph machine learning (FGML) has been extensively surveyed [12], current works are predominantly focused on representation learning, leaving the structured task of “counting” largely unexplored.
Existing FGML works primarily address tasks like node classification and link prediction, where the main challenge is the missing crossgraph neighbor problem caused by graph partitioning. To mitigate this, FedSage+ [33] and FedDep [34] employ generative models to “hallucinate” missing neighbors, thereby restoring connectivity information. FedNI [35] utilizes network inpainting to assist prediction in population graphs, while FedCog [36] introduces a decoupled training strategy to handle coupled graphs efficiently. FedGCN [37] tries to strike a balance between availability and privacy and recover the lost edge information of graph data across clients. Baek et al. [38] proposed FedPub, which personalizes models based on functional similarity among clients. Recent advances in 2025 continue to refine these paradigms: FedStruct [39] proposes a decoupled architecture for graph classification, Fedlog [40] uses synthetic data from multiple clients to complete server-side model training, and FedLap [41] leverages spectral methods to handle system heterogeneity. However, the objective of these methods is to learn high-quality node embeddings for classification, rather than performing precise structural pattern matching and counting, which requires capturing higher-order topological interactions.
Current research on subgraph counting in federated environments, largely motivated by the database query setting, is driven by strict privacy requirements and thus often resorts to heavy cryptographic techniques for exact counting. Yuan et al. [13] designed a framework for subgraph matching over isolated graph databases, focusing on query decomposition rather than learning. For simple motifs like triangles, MAGO [3] achieves maliciously secure counting on decentralized social graphs using homomorphic encryption. Similarly, CARGO [14] and Sectric [15] combine Differential Privacy with Secure Multi-Party Computation to enable triangle counting without trusted servers.
While these cryptography-based methods offer strong privacy guarantees, they suffer from fundamental limitations that hinder their widespread adoption for general counting tasks. First, limited applicability: most methods are hard-coded for specific simple motifs (e.g., triangles or cliques) and lack the flexibility to generalize to arbitrary, complex query patterns required in many real-world applications. Second, accuracy–efficiency trade-off: techniques like Differential Privacy inevitably introduce noise that degrades counting precision—a critical issue for regression tasks—while homomorphic encryption incurs prohibitive computational and communication overheads when handling complex graph matching operations. Consequently, there remains a significant gap between those works and the application requirements: the lack of a general-purpose federated framework capable of learning to count arbitrary complex subgraphs with high precision and efficiency, while leveraging the inherent structural isolation of federated architectures to preserve privacy. This work aims to bridge this gap by exploring a neural-based federated counting paradigm.

3. Preliminary

3.1. Graph Notation

A graph is denoted by  G = ( V G , E G , X G , Y G ) , where  V G  represents a set of nodes,  E G ⊆ V G × V G  represents a set of edges,  X G  is a node label function that maps a node to node labels, and  Y G  is an edge label function that maps an edge to edge labels.
A graph  S = ( V S , E S , X S , Y S )  is a subgraph of  G  if  V S ⊆ V G ,  E S ⊆ ( V S × V S ) ∩ E G , and it preserves the labeling such that  ∀ u , v ∈ V S , X S ( u ) = X G ( u ) , X S ( v ) = X G ( v ) , if  ⟨ u , v ⟩ ∈ E S  then  Y S ( ⟨ u , v ⟩ ) = Y G ( ⟨ u , v ⟩ )  else  Y S ( ⟨ u , v ⟩ ) = ∅ .
In our discussion, an undirected graph is regarded as a bidirectional graph, that is, the connecting edge between the two points  u , v  in an undirected graph is split into  ⟨ u , v ⟩  and  ⟨ v , u ⟩ .

3.2. Subgraph Isomorphism

Definition 1 (Graph Isomorphism).
A graph  G 1  is is isomorphic to another graph  G 2  if and only if there exists a bijective mapping function  ψ : V G 1 → V G 2  such that:
  • ∀ v ∈ V G 1 , ψ ( v ) ∈ V G 2 ;
  • X G 1 ( v ) = X G 2 ( ψ ( v ) ) ;
  • ∀ ⟨ u , v ⟩ ∈ E G 1 , ⟨ ψ ( u ) , ψ ( v ) ⟩ ∈ E G 2 ;
  • Y G 1 ( ⟨ u , v ⟩ ) = Y G 2 ( ⟨ ψ ( u ) , ψ ( v ) ⟩ ) .
We denote that the two graphs  G 1  and  G 2  are isomorphic as  G 1 ≃ G 2 . Theoretically, the graph isomorphism relation is transitive: if  G 1 ≃ G 2  and  G 2 ≃ G 3 , then  G 1 ≃ G 3 .
Definition 2 (Subgraph Isomorphism).
A pattern graph  Q  is subgraph isomorphic to a given input graph  G  if there exists a subgraph  S  of the input graph  G  which is isomorphic to pattern graph  Q .

3.3. Problem Definition

Given an input graph  G  and a query pattern  Q , the problem of subgraph isomorphism counting aims to determine the number of subgraphs in  G  that are isomorphic to  Q . In existing studies, subgraph counting approaches are generally categorized into two types: exact counting and approximate counting. Most existing learning-based methods focus on the approximate counting task. Following this paradigm, this paper also addresses the problem of approximate subgraph isomorphism counting.
We denote the count of subgraph isomorphisms as  c ( G , Q ) . Typically, the query graph  Q  is significantly smaller than the input graph  G , satisfying  | V Q | ≪ | V G |  and  | E Q | ≪ | E G | . As this is a non-trivial #P-Complete problem, the search complexity and space consumption are often computationally prohibitive, making exact enumeration impractical for large graphs.

4. Proposed Approach

In this section, we present the technical details of FedCount. We first introduce the lightweight structural encoding scheme designed for privacy-preserving local counting. We then elaborate on the edge-centric Siamese encoder and the query-conditioned modulation mechanism, followed by the specific objective function used for optimization.

4.1. Framework Overview

We propose FedCount, a privacy-preserving framework designed for general subgraph isomorphism counting across distributed data silos. The framework consists of a central server and a set of K clients, denoted as  C = { C 1 , C 2 , … , C K } . Each client  C k  holds a private local input graph dataset  D k = { ( G i , Q j , c i , j ) } , where each sample consists of a target graph  G i  and the ground-truth count  c i , j  of a specific query pattern  Q j . Crucially, the raw graph data in  D k  never leaves the local device, preserving data sovereignty. The model is illustrated in Figure 1.
Figure 1. Overall framework of FedCount.
The collaborative training process follows a standard federated round, which iterates through the following three steps:
  • Global Distribution: The server broadcasts the current global model parameters  W g ( t )  and the query pattern  Q  to a selected subset of active clients.
  • Local Update: Each client  C k  initializes its local model with  W g ( t )  and performs local training on  D k  to minimize the counting error. This step utilizes our proposed Edge-Centric Counting Model (detailed in Section 4.2, Section 4.3 and Section 4.4) to generate high-quality structural gradients.
  • Aggregation: Clients upload their updated model updates (e.g., gradients or weights) to the server. The server then aggregates these updates to refine the global model for the next round, typically employing FedAvg [11] or FedSGD.
This architecture decouples model training from direct data access, leveraging the structural isolation of clients as a foundational privacy safeguard.

4.2. Local Structural Encoding

Standard GNNs often struggle to distinguish edge-induced subgraphs due to the limitation of the 1-WL test. While recent advanced methods like ESC-GNN [17] improve expressiveness by computing global all-pair distances, such operations are computationally prohibitive for large-scale graphs in federated settings. To balance efficiency and expressiveness, we propose a Lightweight Local Structural Encoding scheme.
We design a hierarchical feature construction strategy that differentiates between generalizable patterns and specific local instances:
  • Generalizable Features ( x [ l , d ] ): Used during the message passing phase. These features consist solely of node/edge Labels (l) and degrees (d). Since these attributes are invariant to node identities, they allow the GNN to learn universal structural patterns that are transferable across different graphs and clients.
  • Specific Features ( x [ e , l , d ] ): Used during the graph modulation phase (see Section 4.4). In addition to labels and degrees, these features incorporate Element Identifiers (e) (i.e., hashed node/edge IDs). This allows the modulation mechanism to distinguish and target specific local substructures within a given input graph.
Formally, let  emb ( · )  denote the embedding lookup function. For an edge  ⟨ u , v ⟩ , its initial representation  h ⟨ u , v ⟩ > ( 0 )  is constructed by explicitly encoding the edge alongside its two endpoints:
h ⟨ u , v ⟩ ( 0 ) = emb ( x u ) ‖ emb ( x ⟨ u , v ⟩ ) ‖ emb ( x v )
where ‖ denotes the concatenation operation and  x  corresponds to the feature set ( x [ l , d ]  or  x [ e , l , d ] ) required by the specific processing stage. This triplet encoding ensures that the edge representation strictly captures the 1-hop local structural context.

4.3. Edge-Level Encoder

To map the topological information of both the query pattern  Q  and the input graph  G  into a latent feature space, we employ a dual-branch framework. Specifically, all input graphs share a common Edge-Level Encoder, and all query patterns share a structurally identical encoder. While these two branches possess the same network architecture to ensure feature compatibility, their parameters can be either distinct or shared depending on the specific configuration.

4.3.1. Edge-to-Edge Message Passing

The core of our encoder is an edge-centric message passing mechanism designed to capture high-order structural interactions. For the l-th layer, the representation of an edge  ⟨ u , v ⟩ , denoted as  h ⟨ u , v ⟩ ( l ) , is updated by aggregating messages from its neighboring edges  N ( ⟨ u , v ⟩ )  (i.e., edges sharing a common node with  ⟨ u , v ⟩ ). The update rule is formulated as
h ⟨ u , v ⟩ ( l ) = σ W 1 ( l ) h ⟨ u , v ⟩ ( l − 1 ) + W 2 ( l ) · AGG { h k ( l − 1 ) ∣ k ∈ N ( ⟨ u , v ⟩ ) } + b ( l )
where  W 1 ( l ) , W 2 ( l )  are learnable weight matrices,  b ( l )  is the bias vector, and  AGG ( · )  is a permutation-invariant aggregation function (e.g., Sum or Mean).

4.3.2. Residual Stacking for Deep Architectures

Capturing large-diameter subgraphs necessitates a deep network architecture. However, training deep GNNs in a federated setting is notoriously unstable due to the gradient vanishing problem. To mitigate this, we implement residual connections across layers. The output of the linear transformation is added to the input of the next layer:
h ⟨ u , v ⟩ ( l ) ← h ⟨ u , v ⟩ ( l ) + h ⟨ u , v ⟩ ( l − 1 )
During the Edge-Level Encoder stage, by integrating the residual mechanism with edge-centric message passing, our encoder achieves robust performance in federated settings. Specifically, the residual connections facilitate direct gradient propagation to earlier layers, effectively mitigating the vanishing gradient problem inherent in deep architectures. This ensures the stable training of models capable of capturing large-diameter subgraphs, even under the periodic aggregation of FedAvg. Simultaneously, the edge-level encoding explicitly models high-order interactions between edges, enabling the network to capture complex topological semantics that are often overlooked by standard node-centric GNNs.

4.4. Query-Conditioned Matching Network

A core challenge in subgraph counting is that different query patterns activate distinct substructures within the same target graph. To address this, we adopt a query-conditioned graph modulation mechanism. Instead of using a static representation for the input graph  G , we utilize Feature-wise Linear Modulation (FiLM) to adaptively highlight edges in  G  that are structurally relevant to the current query  Q .

4.4.1. Query Graph Representation

First, we obtain a global representation vector  h Q  for the query graph. This is achieved by aggregating the final edge embeddings from the query branch encoder:
h Q = σ W Q · AGG e ∈ E Q ( h e ( L ) )
where  W Q  is a learnable projection matrix.

4.4.2. Query-Guided Modulation (FiLM)

We use  h Q  to modulate the edge representations of the input graph. Let  h ⟨ u , v ⟩  denote the embedding of an edge  ⟨ u , v ⟩  in  G  generated by the input branch encoder. We first project it via a linear transformation:  h ⟨ u , v ⟩ ′ = W G h ⟨ u , v ⟩ . Then, we compute the scaling factor  α ⟨ u , v ⟩  and shifting factor  β ⟨ u , v ⟩  dynamically based on both the local edge feature and the global query context:
α ⟨ u , v ⟩ = FCL α , 1 ( h ⟨ u , v ⟩ ′ ) + FCL α , 2 ( h Q ) β ⟨ u , v ⟩ = FCL β , 1 ( h ⟨ u , v ⟩ ′ ) + FCL β , 2 ( h Q )
After that, the modulated edge representation  h ˜ ⟨ u , v ⟩  is obtained via an affine transformation:
h ˜ ⟨ u , v ⟩ = ( α ⟨ u , v ⟩ + 1 ) ⊙ h ⟨ u , v ⟩ ′ + β ⟨ u , v ⟩
Such a mechanism allows the model to selectively amplify edges in  G  that match the structural pattern of  Q  while suppressing irrelevant ones. The final global representation of the input graph is aggregated as  h G = σ ( AGG ( h ˜ ⟨ u , v ⟩ ) ) .

4.4.3. Global Matching and Prediction

To predict the subgraph isomorphism count, we construct a comprehensive interaction feature vector  z m a t c h  by capturing the relationship between the query and the modulated input graph:
z m a t c h = LeakyReLU FCL h Q ‖ h G ‖ ( h G − h Q ) ‖ ( h G ⊙ h Q )
Finally, to assist the regression task with explicit size constraints, we concatenate graph size heuristics to the matching vector. The predicted count  y ^  is computed as
y ^ = FCL o u t z m a t c h ‖ | V G | ‖ | V Q | ‖ 1 | V G | ‖ 1 | V Q |

4.5. Optimization Objective

The training objective of FedCount is designed to ensure high counting precision while maintaining model generalization. The total local loss function  L t o t a l  for a client is composed of three components: the prediction error, the modulation sparsity regularization, and the model parameter regularization.
Prediction Loss ( L p r e d ). Since subgraph isomorphism counting is a regression task, we employ the Mean Absolute Error (MAE) loss to minimize the discrepancy between the predicted count  c ^ i , j  and the ground-truth count  c i , j . MAE is chosen for its robustness to outliers compared to MSE:
L p r e d = 1 | D | ∑ ( G i , Q j , c i , j ) ∈ D | c ^ i , j − c i , j |
Modulation Sparsity Loss ( L F i L M ). To encourage the model to select only the most relevant substructures and suppress noise, we impose an L2 regularization on the Feature-wise Linear Modulation (FiLM) modulation parameters ( α  and  β ). This constraint promotes sparsity in the modulation mechanism, ensuring that the model does not over-activate irrelevant edges:
L F i L M = 1 | D | ∑ i = 1 | D | ∑ ⟨ u , v ⟩ ∈ E G i ∥ α ⟨ u , v ⟩ ∥ 2 2 + ∥ β ⟨ u , v ⟩ ∥ 2 2
Weight Regularization ( L r e g ). Standard L2 regularization is applied to the trainable model parameters  Θ  to prevent overfitting:
L r e g = ∥ Θ ∥ 2 2
Total Objective. The final objective function is a weighted sum of these three terms:
L t o t a l = L p r e d + λ 1 L F i L M + λ 2 L r e g
where  λ 1  and  λ 2  are hyperparameters balancing the trade-off between counting accuracy and structural regularization.

4.6. Federated Training Protocol

Having defined the local counting model and the optimization objective, we now detail the collaborative training process. The goal of FedCount is to minimize the global loss function  L g l o b a l  across K distributed clients without accessing their private graph data  D k .
Let  n k = | D k |  be the number of samples on client k, and  n = ∑ k = 1 K n k  be the total sample size. The global objective is formulated as the weighted average of local losses:
min W L ( W ) = ∑ k = 1 K n k n L k ( W )
where  L k ( W )  is the local objective function defined in Section 4.5. To solve this optimization problem, we implement two standard federated aggregation strategies: FedAvg and FedSGD.

4.6.1. Federated Averaging (FedAvg)

FedAvg [11] is the default protocol in our framework due to its communication efficiency. Instead of communicating every iteration, clients perform multiple epochs of local training before synchronizing with the server.
The process for communication round t is as follows:
  • Server Broadcast: The server sends the current global model parameters  W t  to a subset of selected clients  S t .
  • Local Update: Each client  k ∈ S t  initializes local parameters  W k ← W t  and performs E local epochs of SGD optimization on its private dataset  D k  with learning rate  η :
    W k ← W k − η ∇ L k ( W k ) ( repeated E times )
  • Aggregation: Clients upload their updated parameters  W k ( t + 1 ) . The server aggregates them to produce the new global model:
    W t + 1 ← ∑ k ∈ S t n k n W k ( t + 1 )

4.6.2. Federated SGD (FedSGD)

FedSGD serves as a baseline strategy and can be viewed as a special case of FedAvg where the local epoch  E = 1  and the local batch size encompasses the entire local dataset (Full-Batch Gradient Descent).
In FedSGD, clients compute the exact gradients based on the current global model and upload them directly (or the equivalent one-step weight update) to the server.
The process for communication round t is:
  • Server Broadcast: The server sends  W t  to clients.
  • Gradient Computation: Each client k computes the gradient over its local data:
    g k = ∇ L k ( W t )
  • Aggregation and Update: The server aggregates the gradients and updates the global model:
    W t + 1 ← W t − η ∑ k = 1 K n k n g k
While FedSGD provides more accurate gradient directions, it requires more frequent communication rounds compared to FedAvg to reach convergence. For a comprehensive overview of the proposed framework, the complete training procedure of FedCount, which integrates the local structural encoding, query-conditioned modulation, and federated aggregation, is summarized in Algorithm 1.

4.7. Theoretical Analysis

To rigorously evaluate the efficiency and security of FedCount, we provide a theoretical analysis regarding its computational complexity and privacy guarantees.

4.7.1. Complexity Analysis

The computational cost of FedCount primarily stems from the local client updates, as the server-side aggregation is negligible. Let  | V |  and  | E |  denote the number of nodes and edges in the input graph  G , and let  D a v g  be the average degree.
Time Complexity
The generation of local structural encodings (Section 4.2) involves degree calculation and hashing, which costs  O ( | V | + | E | ) . For the Edge-Level Encoder with L layers (Section 4.3), the message passing operation aggregates information from neighboring edges. The complexity is  O ( L · | E | · D a v g ) . The query-conditioned modulation (Section 4.4) involves element-wise operations on edge features, costing  O ( | E | · d h i d d e n ) . The total time complexity is linear with respect to the number of edges, i.e.,  O ( | E | ) . In contrast, traditional exact subgraph enumeration algorithms (e.g., VF2, Ullmann) exhibit exponential complexity  O ( | V | k )  for a query of size k. This confirms that FedCount is scalable to large-scale graphs.
Space Complexity
Since FedCount operates on edge batches and avoids storing the full adjacency matrix in dense format, the space complexity is  O ( | E | + | V | ) .
Algorithm 1: Federated training protocol for FedCount
Require:  Distributed datasets  { D 1 , … , D K } , Query set  Q , Global epochs T, Local epochs E, Learning rate  η , Hyperparameters  λ 1 , λ 2 .
Ensure:  Trained global model parameters  W g .
  1: Server executes:
  2: Initialize global model parameters  W g ( 0 ) .
  3: for round  t = 0 , 1 , … , T − 1  do
  4:     Server selects a subset of clients  S t ⊆ { 1 , … , K } .
  5:     Server samples a query batch  Q b a t c h ∼ Q .
  6:     Broadcast  W g ( t )  and  Q b a t c h  to all clients in  S t .
  7:     for each client  k ∈ S t  in parallel do
  8:          W k ( t + 1 ) ← ClientUpdate ( k , W g ( t ) , Q b a t c h )
  9:     end for
10:     Aggregation (FedAvg):
11:      W g ( t + 1 ) ← ∑ k ∈ S t | D k | | D S t | W k ( t + 1 )
12: end for
13: return   W g ( T )
14: Function  ClientUpdate ( k , W , Q b a t c h ) :
15: Initialize local model  W k ← W .
16: for local epoch  e = 1 , … , E  do
17:     for batch  B ⊆ D k  do
18:         1. Structural Encoding: Generate edge features  h ( 0 )  using Equation (1).
19:         2. Siamese Encoding: Extract deep features  h ( L )  via Residual GNN using Equations (2) and (3).
20:         3. Modulation: Compute  α , β  and modulate input graph features via FiLM using Equation (5).
21:         4. Prediction: Compute  y ^  and interaction features  z m a t c h  using Equations (7) and (8).
22:         5. Optimization:
23:         Compute Loss:  L ← L M A E + λ 1 L F i L M + λ 2 ∥ W k ∥ 2  according to Equation (12)
24:         Update:  W k ← W k − η ∇ L
25:     end for
26: end for
27: return   W k

4.7.2. Threat Model and Privacy Analysis

We explicitly define our threat model and acknowledge the boundaries of our privacy claims as below.
Threat Model
We assume an “honest-but-curious” server and participating clients. The primary privacy goal of FedCount is to strictly prevent the direct leakage of raw graph topology (adjacency matrix A) and original node/edge features (X) to the server or other clients.
Privacy via Structural Isolation
FedCount achieves this privacy goal primarily through three distinct, lightweight mechanisms:
  • Data Locality: The raw graph topology (adjacency matrix A) and node features (X) never leave the local client. This satisfies the fundamental requirement of data residency.
  • Gradient Obfuscation: Instead of sharing raw data, clients only upload model gradients  ∇ W  or parameter updates. Unlike reconstructing continuous images from gradients (which is feasible in some settings), reverse-engineering discrete graph structures from the gradients of a deep, residual GNN is significantly more challenging. Furthermore, the inherent “many-to-one” mapping of the subgraph counting task (where highly diverse graph topologies can map to the same scalar count) creates an immense solution space, making exact topology reconstruction computationally intractable for potential attackers.
  • Structural Hashing: As introduced in Section 4.2, our lightweight encoding scheme hashes specific structural identities (e.g., node IDs). Even if an attacker intercepts the initial embeddings during transmission, they cannot reverse-engineer the original node mapping without the specific hash keys securely kept on local devices.
Privacy Limitations and Trade-Offs
However, we explicitly tone down the claim of absolute privacy. FedCount currently does not employ heavy cryptographic techniques and thus does not provide formal theoretical guarantees against advanced inference attacks. Specifically, our framework is still susceptible to model inversion, gradient leakage, and membership inference attacks during the aggregation stage.
While integrating additional privacy-preserving techniques could mitigate these risks, they introduce severe practical trade-offs for the subgraph counting task:
  • Differential Privacy (DP): DP injects calibrated noise into the gradients. Since subgraph isomorphism counting is a highly sensitive regression task, the injected noise would drastically degrade the precise counting accuracy required by the model.
  • Secure Aggregation/SMPC: While Secure Multi-Party Computation can prevent the server from inspecting individual gradients, it incurs prohibitive communication and computational overheads, largely negating the efficiency and scalability advantages of our lightweight edge-centric framework.

5. Experiments

5.1. Experimental Setup

5.1.1. Datasets

To comprehensively evaluate the performance and scalability of FedCount, we conduct experiments on four datasets: one real-world molecular dataset (MUTAG), two synthetic datasets (SMALL and LARGE), and a newly curated federated heterophilic social network dataset (SOCIAL). See Table 1 for the statistics of the datasets.
Table 1. Summary of datasets.
Real-world Dataset (MUTAG). We utilize the MUTAG dataset, a standard benchmark consisting of mutagenic aromatic and nitro compounds. Each graph represents a molecule, where nodes correspond to atoms and edges represent chemical bonds. This dataset is employed to assess the model’s capability in capturing structural patterns in realistic scientific domains.
Synthetic Datasets (SMALL & LARGE). To systematically evaluate the model’s robustness across varying graph sizes and densities, we generate two synthetic datasets, denoted as SMALL and LARGE. We employ the generator proposed in [9] to generate random graphs. The specific generation parameters for pattern graphs  Q  and input graphs  G  are detailed in Table 2. The SMALL dataset is designed to evaluate fine-grained counting precision on smaller topologies, while the LARGE dataset tests the scalability of the framework on larger graphs with higher edge densities.
Table 2. Parameters for generating synthetic datasets.
Heterophilic Social Networks (SOCIAL). To rigorously evaluate our framework’s generalizability across diverse graph domains and its robustness against extreme data heterogeneity (Non-IID), we construct a highly skewed federated dataset, denoted as SOCIAL, using four real-world heterophilic networks [42]: Citeseer, Cornell, Texas, and Wisconsin. Rather than utilizing these datasets for traditional node classification, we extract their raw topological structures for subgraph counting. To avoid the computationally prohibitive overhead of exact subgraph enumeration on disconnected noisy fragments, we strictly extract the maximum connected component from each dataset (discarding small isolated components that typically contain only 2–3 nodes). We then assign each component exclusively to a distinct client ( K = 4 ), generate diverse query patterns, and obtain ground-truth counts via the exact solver. This deliberate partitioning creates a highly challenging, extreme Non-IID federated environment characterized by highly skewed graph sizes and vastly different edge densities.
Ground-Truth Generation. The ground-truth subgraph counts are obtained using the VF2 algorithm [43], an exact subgraph isomorphism solver. To explicitly address the computational cost of generating these exact training labels (as discussed in our limitations), the total offline generation time can be systematically derived from our reported statistics. Specifically, the average running time per triplet can be calculated by dividing the total VF2 execution time on the datasets (reported in Table 3) by the number of dataset triples. The exact number of testing, training, and validation samples for each dataset can be precisely determined using the total triples listed in Table 1 combined with the dataset partitioning strategy detailed in Section 5.1.4. Consequently, the total offline label generation time is simply the average per-triplet time multiplied by the sum of the training and validation samples. It is worth noting that while acquiring these exact labels introduces a non-trivial one-time offline cost prior to training, this upfront cost is highly acceptable. The core advantage of our neural framework lies in its ability to completely bypass this exact matching phase during real-world deployment, reducing the subsequent online inference cost to near zero.
Table 3. Performance comparison with baselines.

5.1.2. Baselines

To thoroughly evaluate the performance of FedCount, we compare it against a standard exact solver and three state-of-the-art deep learning-based subgraph counting methods. It is important to note that all neural baselines are trained in a centralized setting, where they have direct access to the aggregated dataset. We use these centralized models to establish a performance upper bound for verifying the efficacy of our federated framework.
  • VF2 [43]: A standard exact subgraph isomorphism algorithm based on a state-space search. It serves as the baseline for evaluating inference efficiency.
  • DiamNet [9]: A neural counting framework that utilizes a Dynamic Intermedium Attention Memory Network. We implement it using RGIN (Relational Graph Isomorphism Network) as the backbone encoder to capture relational structures.
  • Count-GNN [10]: A state-of-the-art method that introduces an edge-centric message passing scheme. It employs a query-conditioned graph modulation mechanism to adaptively match diverse query patterns.
  • DeSCo [31]: A scalable framework designed for generalization. It utilizes a canonical partition strategy to decompose target graphs into neighborhoods, ensuring accurate counting on large-scale graphs.
For fairness, the centralized baselines are trained on the union of all the local datasets  ⋃ k D k , while FedCount is trained under the strict federated setting without data sharing.

5.1.3. Evaluation Metrics

To comprehensively assess the performance of FedCount, we employ two complementary metrics: Mean Absolute Error (MAE) and Q-error.
Mean Absolute Error (MAE). MAE measures the average magnitude of errors between the predicted counts  y ^ i  and the ground-truth counts  y i . It is defined as
MAE = 1 N ∑ i = 1 N | y ^ i − y i |
where N is the total number of test samples. Lower MAE indicates better accuracy.
Q-error. Since subgraph counts often span multiple orders of magnitude, we adopt Q-error to evaluate the relative quality of the predictions. It is defined as the maximum ratio between the prediction and the ground truth:
Q - error ( y i , y ^ i ) = max y ^ i + 1 y i + 1 , y i + 1 y ^ i + 1
Note that we add a smoothing term of 1 to handle zero counts. A perfect prediction yields a Q-error of 1.0. We report the mean Q-error across the test set.

5.1.4. Implementation Details

Data Partitioning Strategy
To simulate a realistic federated learning scenario and strictly enforce an inductive setting, we adopt a graph-wise partitioning strategy. We treat each input graph  G i  as an atomic unit. Specifically, all the triples  { ( G i , Q j , y i j ) ∣ ∀ Q j ∈ Q }  derived from the same input graph are assigned exclusively to the same data split or client. Based on this strategy, the datasets are split as follows:
  • MUTAG: The input graphs are partitioned such that the resulting triples are divided into training, validation, and testing sets with a ratio of 1:1:1.
  • Synthetic (SMALL and LARGE): We partition the input graphs to allocate 5000 samples for training and 1000 samples for validation. All remaining samples are reserved for testing to strictly evaluate generalization.
  • SOCIAL: To simulate an extreme Non-IID scenario, the four maximum connected components (from Citeseer, Cornell, Texas, and Wisconsin) are assigned directly and exclusively to four distinct clients. For each client, the locally generated query triples are partitioned into training, validation, and testing sets, enforcing a strict federated evaluation on highly skewed graph sizes. We divide all triples into 1:1:1 as the training, validation, and testing sets.
In the federated setting, the training graphs are further distributed uniformly among K clients.
Training Setup
We implement FedCount using PyTorch 1.7.1 and DGL 0.4.3.post2. The model is trained using the Adam optimizer with a learning rate of  10 − 3  and weight decay of  5 × 10 − 5  as default. The local batch size is set to 512. Unless otherwise stated, we set the number of clients  K = { 4 , 8 , 16 }  and perform  E = 2  local epochs per communication round. All experiments are conducted on a server with an an Intel(R) Xeon(R) Platinum 8368Q CPU (2.60 GHz) and an NVIDIA L40 GPU with 48 GB of VRAM.

5.2. Results

5.2.1. Overall Performance

Table 3 presents the performance comparison. FedCount achieves the best accuracy across all datasets, consistently outperforming centralized baselines.
Performance on Standard Datasets. On the SMALL dataset, FedCount reduces the MAE by roughly 25% compared to Count-GNN (10.08 vs. 13.43). We attribute this superior performance to the regularization effect of federated learning, which prevents the model from overfitting to specific local structures, thereby learning more generalizable patterns than centralized training. Furthermore, FedCount maintains an exceptionally high inference speed (e.g., 0.02 s on MUTAG), comparable to the highly efficient Count-GNN and drastically outperforming the exact solver VF2.
Robustness on Extreme Non-IID Heterophilic Graphs (SOCIAL). The most striking contrast emerges on the newly introduced SOCIAL dataset, which simulates an extreme federated environment with highly skewed graph sizes and complex heterophilic topologies. Under this rigorous setting, traditional neural baselines exhibit severe performance degradation: DiamNet completely fails to generalize, yielding the highest MAE (104.65) and Q-error (59.48). As an early framework lacking explicit query–target interaction, its global graph pooling mechanism severely struggles on heterophilic graphs. Because connecting nodes possess vastly different features, the local structural semantics are easily over-smoothed or drowned out by heterophilic noise. DeSCo suffers from both poor accuracy (MAE 69.75) and high computational overhead (3.72 s, the slowest among neural methods). Its reliance on subgraph decomposition becomes a massive computational and structural bottleneck when processing highly skewed, irregular maximum connected components, proving it brittle in such extreme Non-IID scenarios. Count-GNN maintains fast inference (0.11 s) but suffers a significant drop in accuracy (MAE 71.02, Q-error 33.82). Although it utilizes edge-centric interactions, it is fundamentally a centralized architecture. When forced to learn across highly heterogeneous clients without our proposed deep residual stabilization, it inevitably falls victim to severe weight divergence and fails to align local topological insights. In stark contrast, FedCount demonstrates remarkable robustness. It achieves the lowest MAE (64.34) and specifically the lowest Q-error (23.09) among all approximate methods, while matching the optimal inference speed (0.11 s). Compared to the computationally prohibitive 629.30 s required by VF2 for exact counting on these massive connected components, FedCount provides a highly practical, privacy-preserving, and fast alternative for analyzing heterophilic data silos.

5.2.2. Ablation Study

To thoroughly evaluate the contributions of our proposed components and training strategies, we conduct ablation studies. For a fair and rigorous comparison, we fix the number of clients to  K = 4  across all datasets, strictly controlling the data distribution variables.
Impact of Architectural Enhancements
We first investigate the necessity of our proposed structural modifications: the lightweight structural encoding and the residual network connections. We compare our final model (FedCount) against a naively federated version of Count-GNN (Fed-CountGNN). As illustrated in Figure 2, the performance exhibits a clear trade-off highly dependent on graph complexity and data heterogeneity. On smaller and topologically simpler graphs (MUTAG and SMALL), the naive architecture performs adequately. In these cases, our deep residual modifications introduce a slight regularization overhead, causing a minor increase in MAE (e.g., from 9.57 to 10.08 on SMALL). However, as the topological complexity drastically increases on the LARGE dataset, the naive GNN struggles with over-smoothing and vanishing gradients, failing to capture complex isomorphism patterns. Here, our architectural enhancements demonstrate their crucial value, explicitly reducing the MAE from 39.17 to 36.75. More importantly, under the extreme Non-IID and heterophilic setting of the newly introduced SOCIAL dataset, the naive Fed-CountGNN suffers severe performance degradation, yielding an MAE of 70.38. In contrast, FedCount effectively mitigates this vulnerability, reducing the MAE to 64.34. This explicitly confirms that our residual connections and lightweight structural encodings are not just beneficial, but essential innovations for maintaining expressiveness when handling highly skewed, large-scale data silos.
Figure 2. Ablation of architectural enhancements ( K = 4 ). Fed-CountGNN refers to the naively federated baseline, while FedCount integrates residual connections and structural encodings.
Impact of Aggregation Strategy
Next, we evaluate the impact of different federated aggregation strategies on our proposed architecture: Model Averaging (FedAvg) and Gradient Averaging (FedSGD). As presented in Figure 3, we observe complex optimization dynamics that diverge from standard federated learning tasks, which are highly dependent on both graph size and client heterogeneity. On the MUTAG and SMALL datasets, FedAvg slightly outperforms FedSGD (e.g., MAE 10.08 vs. 10.29 on SMALL). This is because multiple local epochs allow for the sufficient exploration and extraction of local subgraph patterns when the topologies are relatively simple. Conversely, on the structurally deep but homogeneously distributed LARGE dataset, FedSGD achieves a massive performance advantage, reducing the MAE from 45.97 to 36.75. We attribute this to mitigating the weight divergence problem inherent in deep residual networks: strict global gradient synchronization provides a stable optimization path for complex counting objectives. Crucially, an intriguing phenomenon emerges on the extreme Non-IID SOCIAL dataset, where FedAvg regains the lead over FedSGD (MAE 64.34 vs. 67.65). This represents a classic manifestation of gradient conflict in extreme heterophilic settings. Because the four clients hold radically different social topologies (Citeseer, Cornell, Texas, and Wisconsin), their local gradients point in entirely divergent directions. Enforcing strict Gradient Averaging at every single step (FedSGD) causes severe gradient cancellation, hindering global convergence. FedAvg, by allowing multiple local steps, enables local models to learn meaningful representations of their uniquely heterophilic motifs before averaging, proving more robust in extreme Non-IID environments.
Figure 3. Comparison of aggregation strategies (FedAvg vs. FedSGD) on our proposed architecture ( K = 4 ).

5.2.3. Hyperparameter Analysis

Impact of the Learning Rate and Aggregation Strategy
To deeply understand the optimization dynamics of our framework, we investigate the model’s sensitivity to the local learning rate  η ∈ { 10 − 4 , 2 × 10 − 4 , 5 × 10 − 4 , 10 − 3 }  across all three datasets with a fixed client number ( K = 4 ). We plot the performance of FedAvg and FedSGD separately to uncover their distinct behaviors, as illustrated in Figure 4.
Figure 4. Joint analysis of the Learning Rate and Aggregation Strategy ( K = 4 ). The top row shows the high sensitivity of FedAvg, leading to divergence on LARGE graphs. The bottom row highlights the robustness of FedSGD across different learning rates. X-axes are in logarithmic scale.
The separated curves reveal a profound difference in optimization stability between the two federated strategies:
  • The Sensitivity of FedAvg. As shown in Figure 4a,b, FedAvg exhibits extreme sensitivity to learning rate variations. While a large learning rate ( η = 10 − 3 ) helps the simple MUTAG dataset converge efficiently (lowering MAE to 2.70), it causes catastrophic divergence on the LARGE dataset. The MAE explodes from 45.97 to 57.20, and the Q-error nearly doubles. This severe degradation occurs because taking multiple local steps with a large step size on highly complex graph topologies exacerbates weight divergence.
  • The Robustness of FedSGD. In stark contrast, Figure 4c,d demonstrates the remarkable robustness of FedSGD. Across all learning rates, FedSGD maintains a tightly bounded error margin. Most notably, on the LARGE dataset, even at the highest learning rate, the MAE only fluctuates slightly to 39.65. This compelling evidence solidifies our earlier findings: by enforcing strict global gradient synchronization, FedSGD acts as an optimization stabilizer, neutralizing the gradient oscillations inherently caused by deep residual counting networks on large-scale topologies.
Impact of Client Numbers
We evaluate the scalability and robustness of our proposed framework by varying the number of federated clients  K ∈ { 4 , 8 , 16 }  on the real-world MUTAG dataset. We plot both the Mean Absolute Error (MAE) and Q-error for FedAvg and FedSGD strategies, as shown in Figure 5.
Figure 5. Impact of client numbers (K) on the MUTAG dataset. Both FedAvg and FedSGD demonstrate excellent scalability, with performance remaining stable or improving as data fragmentation increases.
The results exhibit remarkable stability across varying degrees of data fragmentation. Surprisingly, rather than degrading, the performance generally improves or remains highly stable as the number of clients increases. For instance, as shown in Figure 5a, the MAE for FedAvg consistently drops from 2.70 at  K = 4  to 2.42 at  K = 16 . Similarly, FedSGD experiences a sharp performance gain when increasing clients from 4 to 8, achieving the optimal MAE of 2.29 and an optimal Q-error of 1.30.
This phenomenon suggests that distributing the graph data among more clients introduces a beneficial regularization effect. During federated training, aggregating diverse local gradients prevents the global model from overfitting to the specific topological structures of a small number of participants. Both aggregation strategies maintain low error rates even when the dataset is highly partitioned at  K = 16 , confirming the framework’s excellent scalability and practical applicability in real-world data silo scenarios.

6. Conclusions

In this paper, we introduced FedCount, a novel federated learning framework specifically designed for privacy-preserving subgraph counting. By thoughtfully integrating lightweight structural encodings and deep residual connections, FedCount effectively captures complex, long-range isomorphism patterns without ever requiring the centralized collection of sensitive graph data. Our extensive evaluations across both real-world molecular and synthetic graph datasets demonstrate that FedCount achieves highly competitive, and often superior, accuracy compared to state-of-the-art centralized baselines. This counter-intuitive performance gain highlights the beneficial implicit regularization effect of federated training on graph data. Furthermore, our in-depth analyses reveal that FedSGD acts as a mandatory optimization stabilizer for deep residual networks on large graphs, effectively mitigating severe weight divergence caused by Non-IID graph fragmentation.
Despite its effectiveness, FedCount has certain limitations that outline promising directions for future research. First, as an inherent trade-off of our lightweight design, while federated learning fundamentally protects raw data isolation, the exchanged model gradients or updates may still be susceptible to advanced privacy breaches, such as gradient inversion or membership inference attacks. Future work will explore integrating rigorous privacy-enhancing technologies (e.g., adaptive Differential Privacy or efficient Secure Aggregation), focusing on carefully balancing the trade-off between strict privacy guarantees, regression accuracy, and communication overhead.
Second, we acknowledge a practical limitation regarding the training phase: preparing the ground-truth counting labels for local datasets still depends on computationally expensive exact subgraph counting algorithms (e.g., VF2). While FedCount significantly accelerates approximate inference post-training, the initial cost of label generation remains a bottleneck. Future research could explore semi-supervised or self-supervised paradigms to reduce the reliance on exact counting labels.
Furthermore, extending our framework to efficiently handle dynamic graphs with temporally evolving structures, as well as addressing extreme structural heterogeneity (i.e., highly skewed degree distributions) across varied clients, represents an important avenue for deploying federated subgraph counting in complex, real-world environments.

Author Contributions

Conceptualization, J.S. and Q.W.; methodology, J.S. and Q.W.; software, J.S. and Q.W.; validation, J.S. and Q.W.; formal analysis, J.S. and Q.W.; investigation, J.S. and Q.W.; resources, J.S. and Q.W.; data curation, J.S. and Q.W.; writing—original draft preparation, J.S. and Q.W.; writing—review and editing, J.S. and Q.W.; visualization, J.S. and Q.W.; supervision, X.Z.; project administration, X.Z.; funding acquisition, X.Z. All authors have read and agreed to the published version of the manuscript.

Funding

This work was supported in part by the National Key Research and Development Program of China under Grant 2020YFB2103803.

Data Availability Statement

The datasets used in this study are publicly available. The original contributions presented in the study are included in the article. Further inquiries can be directed to the corresponding author.

Acknowledgments

We wish to acknowledge the anonymous referees who gave valuable suggestions to improve the work.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Ribeiro, P.; Paredes, P.; Silva, M.E.; Aparicio, D.; Silva, F. A survey on subgraph counting: Concepts, algorithms, and applications to network motifs and graphlets. ACM Comput. Surv. (CSUR) 2021, 54, 1–36. [Google Scholar] [CrossRef] [Scilit]
  2. Milo, R.; Shen-Orr, S.; Itzkovitz, S.; Kashtan, N.; Chklovskii, D.; Alon, U. Network motifs: Simple building blocks of complex networks. Science 2002, 298, 824–827. [Google Scholar] [CrossRef] [Scilit]
  3. Wang, S.; Zheng, Y.; Jia, X.; Wang, Q.; Wang, C. Mago: Maliciously secure subgraph counting on decentralized social graphs. IEEE Trans. Inf. Forensics Secur. 2023, 18, 2929–2944. [Google Scholar] [CrossRef] [Scilit]
  4. Alon, U. Network motifs: Theory and experimental approaches. Nat. Rev. Genet. 2007, 8, 450–461. [Google Scholar] [CrossRef] [Scilit]
  5. Sporns, O.; Kötter, R. Motifs in brain networks. PLoS Biol. 2004, 2, e369. [Google Scholar] [CrossRef] [Scilit]
  6. Cook, S.A. The complexity of theorem-proving procedures. In Proceedings of the Third Annual ACM Symposium on Theory of Computing; Association for Computing Machinery: New York, NY, USA, 1971; pp. 151–158. [Google Scholar]
  7. Ullmann, J.R. An algorithm for subgraph isomorphism. J. ACM (JACM) 1976, 23, 31–42. [Google Scholar] [CrossRef] [Scilit]
  8. Han, W.S.; Lee, J.; Lee, J.H. Turboiso: Towards ultrafast and robust subgraph isomorphism search in large graph databases. In Proceedings of the 2013 ACM SIGMOD International Conference on Management of Data; Association for Computing Machinery: New York, NY, USA, 2013; pp. 337–348. [Google Scholar]
  9. Liu, X.; Pan, H.; He, M.; Song, Y.; Jiang, X.; Shang, L. Neural subgraph isomorphism counting. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining; Association for Computing Machinery: New York, NY, USA, 2020; pp. 1959–1969. [Google Scholar]
  10. Yu, X.; Liu, Z.; Fang, Y.; Zhang, X. Learning to count isomorphisms with graph neural networks. In Proceedings of the AAAI Conference on Artificial Intelligence; AAAI Press: Washington, DC, USA, 2023; Volume 37, pp. 4845–4853. [Google Scholar]
  11. McMahan, B.; Moore, E.; Ramage, D.; Hampson, S.; y Arcas, B.A. Communication-efficient learning of deep networks from decentralized data. In Proceedings of the Artificial Intelligence and Statistics; PMLR: Cambridge, MA, USA, 2017; pp. 1273–1282. [Google Scholar]
  12. Fu, X.; Zhang, B.; Dong, Y.; Chen, C.; Li, J. Federated graph machine learning: A survey of concepts, techniques, and applications. ACM SIGKDD Explor. Newsl. 2022, 24, 32–47. [Google Scholar] [CrossRef] [Scilit]
  13. Yuan, Y.; Ma, D.; Wen, Z.; Zhang, Z.; Wang, G. Subgraph matching over graph federation. Proc. VLDB Endow. 2021, 15, 437–450. [Google Scholar] [CrossRef] [Scilit]
  14. Liu, S.; Cao, Y.; Murakami, T.; Liu, J.; Yoshikawa, M. CARGO: Crypto-Assisted Differentially Private Triangle Counting without Trusted Servers. In Proceedings of the 2024 IEEE 40th International Conference on Data Engineering (ICDE); IEEE: Piscataway, NJ, USA, 2024; pp. 1671–1684. [Google Scholar]
  15. Xu, M.; Xie, Z.; Wang, Z.; Wang, G.; Lai, L.; Zhang, Y.; Tian, C.; Zhong, S. Sectric: Towards Accurate, Privacy-preserving and Efficient Triangle Counting. Proc. VLDB Endow. 2025, 18, 3382–3395. [Google Scholar] [CrossRef] [Scilit]
  16. Chen, Z.; Chen, L.; Villar, S.; Bruna, J. Can graph neural networks count substructures? Adv. Neural Inf. Process. Syst. 2020, 33, 10383–10395. [Google Scholar]
  17. Yan, Z.; Zhou, J.; Gao, L.; Tang, Z.; Zhang, M. An efficient subgraph gnn with provable substructure counting power. In Proceedings of the 30th ACM SIGKDD Conference on Knowledge Discovery and Data Mining; Association for Computing Machinery: New York, NY, USA, 2024; pp. 3702–3713. [Google Scholar]
  18. Han, M.; Kim, H.; Gu, G.; Park, K.; Han, W.S. Efficient subgraph matching: Harmonizing dynamic programming, adaptive matching order, and failing set together. In Proceedings of the 2019 International Conference on Management of Data; Association for Computing Machinery: New York, NY, USA, 2019; pp. 1429–1446. [Google Scholar]
  19. Ribeiro, P.; Silva, F. G-tries: An efficient data structure for discovering network motifs. In Proceedings of the 2010 ACM Symposium on Applied Computing; Association for Computing Machinery: New York, NY, USA, 2010; pp. 1559–1566. [Google Scholar]
  20. Ribeiro, P.; Silva, F. G-tries: A data structure for storing and finding subgraphs. Data Min. Knowl. Discov. 2014, 28, 337–377. [Google Scholar] [CrossRef] [Scilit]
  21. Pinar, A.; Seshadhri, C.; Vishal, V. Escape: Efficiently counting all 5-vertex subgraphs. In Proceedings of the 26th International Conference on World Wide Web; Association for Computing Machinery: New York, NY, USA, 2017; pp. 1431–1440. [Google Scholar]
  22. Pashanasangi, N.; Seshadhri, C. Efficiently counting vertex orbits of all 5-vertex subgraphs, by evoke. In Proceedings of the 13th International Conference on Web Search and Data Mining; Association for Computing Machinery: New York, NY, USA, 2020; pp. 447–455. [Google Scholar]
  23. Zhang, H.; Yu, J.X.; Zhang, Y.; Zhao, K.; Cheng, H. Distributed subgraph counting: A general approach. Proc. VLDB Endow. 2020, 13, 2493–2507. [Google Scholar] [CrossRef] [Scilit]
  24. Afrati, F.N.; Fotakis, D.; Ullman, J.D. Enumerating subgraph instances using map-reduce. In Proceedings of the 2013 IEEE 29th International Conference on Data Engineering (ICDE); IEEE: Piscataway, NJ, USA, 2013; pp. 62–73. [Google Scholar]
  25. Lai, L.; Qin, L.; Lin, X.; Zhang, Y.; Chang, L.; Yang, S. Scalable distributed subgraph enumeration. Proc. VLDB Endow. 2016, 10, 217–228. [Google Scholar] [CrossRef] [Scilit]
  26. Zhao, K.; Yu, J.X.; Zhang, H.; Li, Q.; Rong, Y. A learned sketch for subgraph counting. In Proceedings of the 2021 International Conference on Management of Data; Association for Computing Machinery: New York, NY, USA, 2021; pp. 2142–2155. [Google Scholar]
  27. Liu, X.; Song, Y. Graph convolutional networks with dual message passing for subgraph isomorphism counting and matching. In Proceedings of the AAAI Conference on Artificial Intelligence; AAAI Press: Washington, DC, USA, 2022; Volume 36, pp. 7594–7602. [Google Scholar]
  28. Wang, H.; Hu, R.; Zhang, Y.; Qin, L.; Wang, W.; Zhang, W. Neural subgraph counting with wasserstein estimator. In Proceedings of the 2022 International Conference on Management of Data; Association for Computing Machinery: New York, NY, USA, 2022; pp. 160–175. [Google Scholar]
  29. Zhao, K.; He, Z.; Yu, J.X.; Rong, Y. Learning with small data: Subgraph counting queries. Data Sci. Eng. 2023, 8, 292–305. [Google Scholar] [CrossRef] [Scilit]
  30. Liu, X.; Wang, W.; Bai, J.; Song, Y. Towards Subgraph Isomorphism Counting with Graph Kernels. arXiv 2024, arXiv:2405.07497. [Google Scholar] [CrossRef] [Scilit]
  31. Fu, T.; Wei, C.; Wang, Y.; Ying, R. Desco: Towards generalizable and scalable deep subgraph counting. In Proceedings of the 17th ACM International Conference on Web Search and Data Mining; Association for Computing Machinery: New York, NY, USA, 2024; pp. 218–227. [Google Scholar]
  32. Ban, L.; Han, X.; Li, J.; Ma, C. UnG-MoCha: Neural Motif Counting in Uncertain Graphs. In Proceedings of the 31st ACM SIGKDD Conference on Knowledge Discovery and Data Mining V. 2; Association for Computing Machinery: New York, NY, USA, 2025; pp. 95–106. [Google Scholar]
  33. Zhang, K.; Yang, C.; Li, X.; Sun, L.; Yiu, S.M. Subgraph federated learning with missing neighbor generation. Adv. Neural Inf. Process. Syst. 2021, 34, 6671–6682. [Google Scholar]
  34. Zhang, K.; Sun, L.; Ding, B.; Yiu, S.M.; Yang, C. Deep efficient private neighbor generation for subgraph federated learning. In Proceedings of the 2024 SIAM International Conference on Data Mining (SDM); SIAM: Philadelphia, PA, USA, 2024; pp. 806–814. [Google Scholar]
  35. Peng, L.; Wang, N.; Dvornek, N.; Zhu, X.; Li, X. Fedni: Federated graph learning with network inpainting for population-based disease prediction. IEEE Trans. Med. Imaging 2022, 42, 2032–2043. [Google Scholar] [CrossRef] [Scilit]
  36. Lei, R.; Wang, P.; Zhao, J.; Lan, L.; Tao, J.; Deng, C.; Feng, J.; Wang, X.; Guan, X. Federated learning over coupled graphs. IEEE Trans. Parallel Distrib. Syst. 2023, 34, 1159–1172. [Google Scholar] [CrossRef] [Scilit]
  37. Yao, Y.; Jin, W.; Ravi, S.; Joe-Wong, C. FedGCN: Convergence-communication tradeoffs in federated training of graph convolutional networks. Adv. Neural Inf. Process. Syst. 2023, 36, 79748–79760. [Google Scholar]
  38. Baek, J.; Jeong, W.; Jin, J.; Yoon, J.; Hwang, S.J. Personalized subgraph federated learning. In Proceedings of the International Conference on Machine Learning; PMLR: Cambridge, MA, USA, 2023; pp. 1396–1415. [Google Scholar]
  39. Aliakbari, J.; Östman, J.; i Amat, A.G. Decoupled Subgraph Federated Learning. In Proceedings of the Thirteenth International Conference on Learning Representations; Morgan Kaufmann Publishers Inc.: San Francisco, CA, USA, 2025. [Google Scholar]
  40. Kim, S.; Lee, Y.; Oh, Y.; Lee, N.; Yun, S.; Lee, J.; Kim, S.; Yang, C.; Park, C. Subgraph Federated Learning for Local Generalization. In Proceedings of the Thirteenth International Conference on Learning Representations; Morgan Kaufmann Publishers Inc.: San Francisco, CA, USA, 2025. [Google Scholar]
  41. Aliakbari, J.; Östman, J.; Panahi, A.; i Amat, A.G. Subgraph Federated Learning via Spectral Methods. In Proceedings of the Thirty-Ninth Annual Conference on Neural Information Processing Systems. 2025. Available online: https://neurips.cc/virtual/2025/loc/san-diego/poster/115411 (accessed on 1 March 2026).
  42. Luan, S.; Hua, C.; Xu, M.; Lu, Q.; Zhu, J.; Chang, X.W.; Fu, J.; Leskovec, J.; Precup, D. When do graph neural networks help with node classification? investigating the homophily principle on node distinguishability. Adv. Neural Inf. Process. Syst. 2023, 36, 28748–28760. [Google Scholar]
  43. Cordella, L.P.; Foggia, P.; Sansone, C.; Vento, M. A (sub) graph isomorphism algorithm for matching large graphs. IEEE Trans. Pattern Anal. Mach. Intell. 2004, 26, 1367–1372. [Google Scholar] [CrossRef] [Scilit] [PubMed]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.