On the number of small edge-weighted subgraphs
Feng Yu, Mingao Yuan
TL;DR
This paper addresses exact counting of small edge-weighted subgraphs in weighted networks by grounding the counts in the weighted adjacency matrix $A$ and expressing the labeled subgraph count as $L = \sum_{i_1\neq i_2\neq \cdots \neq i_m} F(i_1,\ldots,i_m)$. It introduces a general, partition-based framework with distinct-block sums $S_\pi$ and general-block sums $M_\pi$ linked by $M_\pi = \sum_{\sigma\succeq\pi} S_\sigma$, with Möbius inversion used to recover $S_{\hat{0}}$, the target distinct-index count. The authors provide explicit closed-form formulas for all connected subgraphs with up to five nodes, including $\sum_{i\neq j\neq k} A_{ij}A_{jk}A_{ki} = \mathrm{tr}(A^3)$ and analogous 4- and 5-node expressions built from traces, Hadamard powers, and tensor contractions, along with a practical, non-loop algorithm verified numerically. This yields a scalable analytical toolkit for both weighted and unweighted graphs, enabling fast subgraph statistics in network analysis and highlighting implementation considerations such as memory management for larger clique-based contractions.
Abstract
Subgraph counting is a fundamental task that underpins several network analysis methodologies, including community detection and graph two-sample tests. Counting subgraphs is a computationally intensive problem. Substantial research has focused on developing efficient algorithms and strategies to make it feasible for larger unweighted graphs. Implementing those algorithms can be a significant hurdle for data professionals or researchers with limited expertise in algorithmic principles and programming. Furthermore, many real-world networks are weighted. Computing the number of weighted subgraphs in weighted networks presents a computational challenge, as no efficient algorithm exists for the worst-case scenario. In this paper, we derive explicit formulas for counting small edge-weighted subgraphs using the weighted adjacency matrix. These formulas are applicable to unweighted networks, offering a simple and highly practical analytical tool for researchers across various scientific domains. In addition, we introduce a generalized methodology for calculating arbitrary weighted subgraphs.
