We consider the problem of counting 4-cycles ($C_4$) in a general undirected graph $G$ of $n$ vertices and $m$ edges (in bipartite graphs, 4-cycles are also often referred to as $\textit{butterflies}$). There have been a number of previous algorithms for this problem; some of these are based on fast matrix multiplication, which is attractive theoretically but not practical, and some of these are based on randomized hash tables. We develop a new simpler algorithm for counting $C_4$ requiring $O(m\bar\delta(G))$ time and $O(n)$ space, where $\bar \delta(G) \leq O(\sqrt{m})$ is the $\textit{average degeneracy}$ parameter introduced by Burkhardt, Faber & Harris (2020). It has several practical improvements over previous algorithms; for example, it is fully deterministic, does not require any sorting of the adjacency list of the input graph, and avoids any expensive arithmetic in its inner loops. To the best of our knowledge, all previous efficient algorithms for $C_4$ counting have required $\Omega(m)$ space. The algorithm can also be adapted to count 4-cycles incident to each vertex and edge.
翻译:我们考虑在包含$n$个顶点和$m$条边的一般无向图$G$中计数4-环($C_4$)的问题(在二分图中,4-环也常被称为$\textit{蝴蝶}$)。此前已有多种解决该问题的算法:其中一些基于快速矩阵乘法(理论上具有吸引力但不实用),另一些则基于随机哈希表。我们提出了一种新的更简单的计数$C_4$算法,该算法需要$O(m\bar\delta(G))$时间和$O(n)$空间,其中$\bar \delta(G) \leq O(\sqrt{m})$是由Burkhardt、Faber和Harris(2020)引入的$\textit{平均退化度}$参数。与先前算法相比,该算法具有多项实际改进:例如,它是完全确定性的,无需对输入图的邻接表进行任何排序,且在内层循环中避免了昂贵的算术运算。据我们所知,此前所有高效的$C_4$计数算法均需要$\Omega(m)$空间。该算法还可调整用于计算每个顶点和边关联的4-环数量。