Table of Contents
Fetching ...

Simple and efficient four-cycle counting on sparse graphs

Paul Burkhardt, David G. Harris

TL;DR

This paper develops a streamlined version of the Wang et al. (2019) algorithm, which is fully deterministic, does not require any auxiliary storage or sorting of the input graph, and uses only addition and array access in its inner loops.

Abstract

We consider the problem of counting 4-cycles ($C_4$) in an undirected graph $G$ of $n$ vertices and $m$ edges (in bipartite graphs, 4-cycles are also often referred to as $\textit{butterflies}$). Most recently, Wang et al. (2019, 2022) developed algorithms for this problem based on hash tables and sorting the graph by degree. Their algorithm takes $O(m\barδ)$ expected time and $O(m)$ space, where $\bar δ\leq O(\sqrt{m})$ is the $\textit{average degeneracy}$ parameter introduced by Burkhardt, Faber \& Harris (2020). We develop a streamlined version of this algorithm requiring $O(m\barδ)$ time and precisely $n$ words of space. It has several practical improvements and optimizations; for example, it is fully deterministic, does not require any auxiliary storage or sorting of the input graph, and uses only addition and array access in its inner loops. Our algorithm is very simple and easily adapted to count 4-cycles incident to each vertex and edge. Empirical tests demonstrate that our array-based approach is $4\times$ -- $7\times$ faster on average compared to popular hash table implementations.

Simple and efficient four-cycle counting on sparse graphs

TL;DR

This paper develops a streamlined version of the Wang et al. (2019) algorithm, which is fully deterministic, does not require any auxiliary storage or sorting of the input graph, and uses only addition and array access in its inner loops.

Abstract

We consider the problem of counting 4-cycles () in an undirected graph of vertices and edges (in bipartite graphs, 4-cycles are also often referred to as ). Most recently, Wang et al. (2019, 2022) developed algorithms for this problem based on hash tables and sorting the graph by degree. Their algorithm takes expected time and space, where is the parameter introduced by Burkhardt, Faber \& Harris (2020). We develop a streamlined version of this algorithm requiring time and precisely words of space. It has several practical improvements and optimizations; for example, it is fully deterministic, does not require any auxiliary storage or sorting of the input graph, and uses only addition and array access in its inner loops. Our algorithm is very simple and easily adapted to count 4-cycles incident to each vertex and edge. Empirical tests demonstrate that our array-based approach is -- faster on average compared to popular hash table implementations.
Paper Structure (13 sections, 10 theorems, 8 equations, 6 figures, 6 tables, 8 algorithms)

This paper contains 13 sections, 10 theorems, 8 equations, 6 figures, 6 tables, 8 algorithms.

Key Result

Theorem 1

Counting 4-cycles in a graph $G$ takes $O(m\bar{\delta})$ time and $n$ space.

Figures (6)

  • Figure 1: A simple cycle of length 4 ($C_4$).
  • Figure 2: A 4-clique and its unique $C_4$'s.
  • Figure 3: Array (Algorithm \ref{['alg:c4']}) versus hash table (Algorithm \ref{['alg:c4hash']}) for counting $\lozenge(G)$.
  • Figure 4: Array (Algorithm \ref{['alg:c4vertex']}) versus hash table (Algorithm \ref{['alg:c4vertex_hash']}) for counting $\lozenge(v)$.
  • Figure 5: Array (Algorithm \ref{['alg:c4edge']}) versus hash table (Algorithm \ref{['alg:c4edge_hash']}) for counting $\lozenge(e)$.
  • ...and 1 more figures

Theorems & Definitions (16)

  • Theorem 1
  • Theorem 2
  • Theorem 3
  • Theorem 4
  • Proposition 1
  • proof
  • Proposition 2
  • proof
  • Proposition 3
  • proof
  • ...and 6 more