Since counting subgraphs in general graphs is, by and large, a computationally demanding problem, it is natural to try and design fast algorithms for restricted families of graphs. One such family that has been extensively studied is that of graphs of bounded degeneracy (e.g., planar graphs). This line of work, which started in the early 80’s, culminated in a recent work of Gishboliner et al., which highlighted the importance of the task of counting homomorphic copies of cycles (i.e., cyclic walks) in graphs of bounded degeneracy.
Our main result in this paper is a surprisingly tight relation between the above task and the well-studied problem of detecting (standard) copies of directed cycles in general directed graphs. More precisely, we prove the following:
•
One can compute the number of homomorphic copies of C2k and C2k+1 in n-vertex graphs of bounded degeneracy in time Õ(ndk), where the fastest known algorithm for detecting directed copies of Ck in general m-edge digraphs runs in time Õ(mdk).
•
Conversely, one can transform any O(nbk) algorithm for computing the number of homomorphic copies of C2k or of C2k+1 in n-vertex graphs of bounded degeneracy, into an Õ(mbk) time algorithm for detecting directed copies of Ck in general m-edge digraphs.
We emphasize that our first result does not use a black-box reduction (as opposed to the second result which does). Instead, we design an algorithm for computing the number of Ck-homomorphisms in degenerate graphs and show that one part of its analysis can be reduced to the analysis of the fastest known algorithm for detecting directed cycles in general digraphs, which was carried out in a recent breakthrough of Dalirrooyfard, Vuong and Vassilevska Williams. As a by-product of our algorithm, we obtain a new algorithm for detecting k-cycles in directed and undirected graphs of bounded degeneracy that is faster than all previously known algorithms for 7 ≤ k ≤ 11, and faster for all k ≥ 7 if the matrix multiplication exponent is 2.
1 Introduction
Counting occurrences of small subgraphs in a given input graph is among the most fundamental algorithmic problems. Most prominently, it is the subject of a rich line of research in parameterized complexity theory [12, 13, 15, 18, 19, 25, 27, 31, 36], which has by now produced several important general results on the fixed-parameter tractability of subgraph counting problems [15, 19, 25]. Works in this area are too numerous to survey here, so we refer the reader to the above-cited papers for further references. On the practical side of things, subgraph counting is important due to the role played by subgraph counts in the analysis of real-world networks, see, e.g., [28, 32], and the references therein.
1.1 Detecting and Counting Cycles
One of the most fundamental and well-studied cases of subgraph-counting is that of counting (and detecting) cycles. Such questions have been studied in both undirected and directed graphs. We will always denote by \(n\) the number of vertices of the input graph and by \(m\) its number of edges. The problem of counting copies of a \(k\) -length cycle is known to be \(\#W[1]\) -hard [18], meaning that it is unlikely to admit an algorithm which runs in time \(f(k) \cdot n^{O(1)}\) for any computable function \(f\) . For cycle detection, however, efficient algorithms exist and are the subject of numerous works [3, 4, 16, 21, 22, 29, 38, 39]. Notably, Alon, Yuster, and Zwick [4] presented several cycle detection algorithms for both the undirected and directed settings, improving upon earlier results of Itai and Rodeh [21] and Monien [29]. Some of these algorithms used the technique of color-coding, introduced earlier in [3]. Most relevant for us is the problem of detecting directed cycles in digraphs, where [4] provided a classical algorithm that detects a directed \(k\) -cycle (for a fixed \(k\) ) in an \(m\) -edge directed graph running in time
This is still the fastest combinatorial algorithm for directed \(k\) -cycle detection in terms of \(m\) ; see the remark at the end of Section 1.4 concerning its optimality. However, faster algorithms exist if we use algebraic algorithms relying on fast matrix multiplication. Let \(\omega\) denote the exponent of fast matrix multiplication, namely the infimum over all constants \(t\) such that two \(n \times n\) matrices can be multiplied using \(\tilde{O}(n^t)\) field operations. It is known that \(\omega \lt 2.373\) [2, 23]. Indeed, motivated by a simple \(O(m^{2\omega /(\omega +1)})\) time algorithm of [4] for detecting a 3-cycle, Yuster and Zwick [38] set out to use fast matrix multiplication for \(k\) -cycle detection (for a fixed \(k\) ). They obtained an algorithm running in time \(\tilde{O}(m^{c_k})\) , and were able to show that for \(k=4,5\) , the value of \(c_k\) (which they explicitly computed for \(k=4,5\) ) is strictly smaller than \(2-1/\lceil k/2 \rceil\) , thereby improving upon the aforementioned combinatorial algorithm. It is, to date, the fastest algorithm for directed \(k\) -cycle detection when \(k=4,5\) in terms of \(m\) . For \(k \ge 6\) , the exact value of \(c_k\) turned out to be hard to analyze, due to an involved use of dynamic programming, which resulted in a complicated recursive relation. This led Yuster and Zwick to raise a conjecture1 regarding the runtime of their algorithm (i.e., the value of \(c_k\) ). This conjecture was recently resolved by Dalirrooyfard, Vuong, and Vassilevska Williams [14], establishing that the algorithm of Yuster and Zwick detects a directed \(k\) -cycle in a graph with \(m\) edges in time \(\tilde{O}(m^{c_k})\) , where2
\begin{align} c_k & \le \frac{(k+1)\omega }{2\omega + k-1} \qquad \qquad \mbox{if } k \mbox{ is odd,} \\ c_k & \le \frac{k\omega - \frac{4}{k}}{2\omega + k-2-\frac{4}{k}} \qquad \, \mbox{if } k \mbox{ is even.} \nonumber \nonumber \end{align}
(2)
It should be noted that equality holds in the odd case when \(\omega \le \frac{2k}{k-1}\) .3 Moreover, it was proved in [14] that equality holds also in the even case if \(\omega =2\) and the exact value of \(c_6\) was determined for all \(\omega\) . To date, for any pair \((k,\omega)\) with \(k \ge 3\) and \(2 \le \omega \lt 2.373\) , the fastest algorithm for detecting a directed \(k\) -cycle in a directed \(m\) -edge graph (i.e., in terms of \(m\) alone) is either the combinatorial \(O(m^{2-1/\lceil k/2 \rceil })\) algorithm or the \(\tilde{O}(m^{c_k})\) algorithm (which of them is faster depends on \((k,\omega)\) ). It is easy to verify that if \(\omega \gt 2\) , then for all large enough \(k\) the \(O(m^{2-1/\lceil k/2 \rceil })\) is faster, while if \(\omega = 2\) then \(\tilde{O}(m^{c_k})\) is always faster, and \(c_k\) is approximately \(2 - \frac{4}{k}\) in this case (for \(k\) large).
1.2 Counting Homomorphisms in Degenerate Graphs
In this work we are concerned with the problem of counting homomorphisms of cycles (i.e., cyclic walks of a given length) in graphs of bounded degeneracy.4 Arguably, homomorphism-counting is the most basic subgraph counting problem, to which other natural problems — such as counting copies or induced copies — can be reduced [12].
Recall that a graph is called \(d\) -degenerate if it admits a vertex ordering \(v_1,\dots ,v_n\) such that \(v_i\) has at most \(d\) neighbors among \(v_{i+1},\dots ,v_n\) (for every \(1 \le i \le n\) ). In the setting considered here, we look for algorithms which run in time \(f(d) \cdot n^{\alpha }\) , where \(d\) is the degeneracy5 of the input graph, \(n\) is its number of vertices, and \(\alpha\) does not depend on \(d\) . Such algorithms are particularly useful when the input graph has bounded degeneracy. The family of such graphs is rich, including for example all non-trivial minor-closed graph classes (in particular, planar graphs), preferential attachment graphs [5], and bounded expansion graphs [30].
The study of subgraph counting in degenerate graphs goes back to a classical work of Chiba and Nishizeki [11] from the early 1980s. Very recently, this research direction has seen several substantial developments [6, 7, 8, 10]. Bressan [10] gave a general algorithm for counting homomorphisms in bounded-degeneracy graphs, which in particular implies a sufficient condition6 (on graphs \(H\) ) under which \(H\) -homomorphisms can be counted in time \(\tilde{O}(n)\) . In [6], it was shown that this sufficient condition is also necessary, and moreover, a clean combinatorial characterization of the graphs \(H\) satisfying it was obtained. Specifically, it was shown that \(H\) -homomorphisms in bounded-degeneracy graphs can be counted in time \(\tilde{O}(n)\) if and only if \(H\) contains no induced cycles of length 6 or larger.7 A similar result has been independently obtained in [8]. These results highlight the important role played by cycles of length at least 6, as being the minimal graphs whose homomorphisms cannot be counted in (almost) linear time (in bounded-degeneracy graphs). This motivates the study of the time complexity of counting homomorphisms of such cycles (with the intention of improving the running time of Bressan’s general algorithm for cycles), which is precisely the question studied in the present paper.
1.3 Our Results
Let \(C_k\) denote the cycle of length \(k\) (where \(k\) is fixed throughout the paper). Here we state our results regarding the problem of counting \(C_k\) -homomorphisms in graphs of bounded degeneracy. By the aforementioned result of Bressan [10], if \(3 \le k \le 5\) then \(C_k\) -homomorphisms can be counted in near-linear time (which is optimal), and we therefore focus on the case \(k \ge 6\) . As our main results in this paper show, the problem of counting \(C_{2k}\) - and \(C_{2k+1}\) -homomorphisms in bounded-degeneracy graphs is related to the problem of detecting directed \(k\) -cycles in general (i.e., not necessarily degenerate) digraphs. In particular, we shall design two algorithms: a combinatorial algorithm for counting cycle homomorphisms whose runtime corresponds to the runtime of the combinatorial \(k\) -cycle detection algorithm of [4], and an algorithm for counting cycle homomorphisms whose runtime obeys the same recursive relation as the aforementioned directed-cycle detection algorithm of Yuster and Zwick [38]. Combining these two algorithms and the work of Dalirrooyfard, Vuong and Vassilevska Williams [14], we will obtain the following theorem, which is our main result in this paper. Let \({\rm\small HOM-CNT}_{H}\) denote the problem of computing the number of \(H\) -homomorphisms.
The algorithm of case (i) in Theorem 1 combines the general structure of the Yuster-Zwick algorithm with several significant additional twists used in the setting of degenerate graphs, inspired by the approach in [10].
As opposed to the algorithm of case (i) which relies on fast matrix multiplication, the algorithm of case (ii) is purely combinatorial. Furthermore, it can be modified to give a combinatorial algorithm for counting \(C_k\) -homomorphisms in general (i.e., not necessarily degenerate) graphs, both directed and undirected, which runs in time \(\tilde{O}(m^{2-1/\lceil k/2 \rceil })\) . This algorithm can in turn be used to obtain a new combinatorial algorithm for directed \(k\) -cycle detection, which essentially matches the runtime of the best such combinatorial algorithm to date, namely the algorithm of [4] mentioned above, while being somewhat simpler. It should be noted that another combinatorial cycle-detection algorithm with the same runtime was given in [37] (see also [22]). The details appear in Section 7.
The relation to directed-cycle detection is in fact more robust, as is evidenced by our next result, which states that counting \(C_{2k}\) - or \(C_{2k+1}\) -homomorphisms already in 2-degenerate graphs is at least as hard as detecting a directed \(k\) -cycle in general digraphs. Note that if \(k=2\) then both problems can be solved in time linear in the number of edges, so the interesting case is when \(k \ge 3\) . Formally, we prove the following theorem.
To make the relation between directed-cycle detection in general graphs and counting cycle homomorphisms in bounded-degeneracy graphs even sharper, recall that for all \(k \ge 3\) , the presently fastest \(k\) -cycle detection algorithm in \(m\) -edge directed graphs is either the \(O(m^{2-1/\lceil k/2 \rceil })\) algorithm [4] or the \(\tilde{O}(m^{c_k})\) algorithm [14, 38]. Let us therefore define for a given \(2 \le \omega \lt 2.373\)
Recall that if \(\omega \gt 2,\) then for all large enough \(k\) we have \(d_k = 2-1/{\lceil k/2 \rceil }\) (i.e., the second term is smaller), while if \(\omega = 2,\) then \(d_k = c_k\) for all \(k \ge 3\) . The following corollary immediately follows from Theorems 1 and 2.
In particular, for every \(\varepsilon \gt 0\) , if we can improve the bound in Theorem 1 and compute, say, \({\rm\small HOM-CNT}_{C_{2k}}\) in time \(O(n^{d_k-\varepsilon })\) , then we could decide if a digraph with \(m\) edges has a directed \(k\) -cycle in time \(O(m^{d_k-\varepsilon })\) , which is faster (in terms of \(m\) ) than the presently fastest known algorithm for the latter problem.
Another interesting by-product of Theorem 1 is that it can be used (together with a standard application of the color-coding method) to give an algorithm for (directed or undirected) \(k\) -cycle detection in bounded-degeneracy graphs.
As can easily be verified by examining the values of \(c_k\) (hence \(d_k\) ), the algorithm of Theorem 4 is faster than any known algorithm for cycle detection in degenerate graphs for \(7 \le k \le 11\) . If \(\omega = 2\) , it is faster for all \(k \ge 7\) . In any case it is never slower (up to polylogarithmic factors) than the previously fastest algorithm for this problem, given in [4], Theorem 4.2.
Let us give some more details of the proof of Theorem 1. For (di)graphs \(G,H\) , let us denote by \(\hom (H,G)\) the number of homomorphisms from \(H\) to \(G\) . Suppose that we want to compute \(\hom (C_{\ell },G)\) for a given \(d\) -degenerate input graph \(G\) . As is usual when working with degenerate graphs, we approach this task by first finding a degeneracy ordering8 \(v_1,\dots ,v_n\) of \(G\) — i.e., a vertex ordering in which each vertex \(v_i\) has at most \(d\) neighbors succeeding it — and then considering the orientation \(\vec{G}\) of \(G\) in which all edges are oriented forward with respect to this ordering, namely, from \(v_i\) to \(v_j\) for \(\lbrace v_i,v_j\rbrace \in E(G)\) with \(i \lt j\) . Observe that \(\vec{G}\) can be obtained in linear time (in \(|E(G)|=O(dn)\) ), that it is acyclic, and that all of its vertices have out-degree at most \(d\) . Moreover, it is not hard to see that \(\hom (C_\ell ,G) = \sum _{\vec{H}}{\hom (\vec{H},\vec{G})}\) , where \(\vec{H}\) runs over all acyclic orientations of \(C_{\ell }\) . It follows that counting \(C_{\ell }\) -homomorphisms in \(d\) -degenerate graphs reduces to counting homomorphisms of (all) acyclic orientations of \(C_{\ell }\) in directed acyclic graphs (DAGs) of maximum out-degree \(d\) .
As it turns out, there is a particular orientation of \(C_{\ell }\) which is harder, in a sense, than all others; this is the orientation with the maximum number of sources, namely, the orientation where edges are oriented in an alternating fashion (with the exception of one edge in the case that \(\ell\) is odd). We call this the alternating orientation of \(C_{\ell }\) . To establish that this is indeed the “hardest orientation”, we show (roughly speaking) that for every DAG \(\vec{H}\) and for every directed subdivision \(\vec{H}^{\prime }\) of \(\vec{H}\) , counting \(\vec{H}^{\prime }\) -homomorphisms can be reduced to counting \(\vec{H}\) -homomorphisms (in input DAGs of bounded maximum degree). It is easy to see that every acyclic orientation \(\vec{H}\) of \(C_{\ell }\) (with at least two sources) is a directed subdivision of the alternating orientation of \(C_{\ell ^{\prime }}\) for some even \(\ell ^{\prime } \le \ell\) , and that \(\ell ^{\prime } = \ell\) if and only if \(\vec{H}\) itself is alternating.9 It follows that the running time of counting \(C_{\ell }\) -homomorphisms is dominated by the running time of counting homomorphisms of alternating orientations of cycles of even length at most \(\ell\) .
The aforementioned general reduction for directed subdivisions is stated in the following theorem. For technical reasons, the reduction reduces the problem of counting \(\vec{H^{\prime }}\) -homomorphisms to the problem of counting \(\vec{H}\) -homomorphisms in weighted digraphs. We denote by \({\rm\small W-HOM-CNT}_{\vec{H}}\) the weighted analogue of \({\rm\small HOM-CNT}_{\vec{H}}\) ; see Section 3 for the precise definition.
We believe Theorem 5 to be of independent interest. With this theorem at hand, it remains to give an efficient algorithm which counts homomorphisms of the alternating orientation of \(C_{2k}\) (in DAGs of bounded maximum out-degree) for every \(k \ge 3\) , which is the main step towards proving Theorem 1. Since applying Theorem 5 requires that the algorithm works in the more general weighted setting, we need to modify it accordingly (this modification is straightforward and does not pose additional difficulties).
1.4 Related Work
While the fastest algorithm for \(k\) -cycle detection in directed \(m\) -edge graphs runs in \(\tilde{O}(m^{d_k})\) time, it is worth noting that there are other algorithms expressed in terms of both \(n\) and \(m\) (or \(n\) alone). Indeed, the color-coding method [3] shows that a simple directed or undirected cycle of size \(k\) in a directed or undirected graph can be detected in either \(\tilde{O}(nm)\) time or \(\tilde{O}(n^\omega)\) time. For dense graphs, this is faster than the \(\tilde{O}(m^{d_k})\) time algorithm. Eisenbrand and Grandoni [16] proved that a directed \(C_4\) can be detected in time \(O(m^{2-2/\omega }n^{1/\omega })\) . This algorithm is inferior to the \(\tilde{O}(m^{c_k})\) algorithm for sparse graphs and inferior to the \(O(n^\omega)\) algorithm for dense graphs, but is better than both in some intermediate range.
As for hardness, Lincoln et al. [22] proved conditional lower bounds for \(k\) -cycle detection. Under a widely-believed assumption, \(K_k\) cannot be detected faster than \(O(C(n,k))\) time, where \(C(n,k) = M(n^{\lceil k/3 \rceil },n^{\lfloor k/3 \rfloor },n^{\lceil (k-1)/3 \rceil })\) and where \(M(a,b,c)\) is the fastest known runtime for multiplying an \(a \times b\) by a \(b \times c\) matrix. Assuming this, they proved that detecting a directed \(k\) -cycle in an \(m\) -edge graph requires \(m^{\frac{2\omega k}{3(k+1)}-o(1)}\) time. The same reduction also shows that any combinatorial algorithm for detecting a directed \(k\) -cycle in an \(m\) -edge graph requires \(m^{2-1/\lceil k/2 \rceil - o(1)}\) time, in this case under the suitable hardness hypothesis that any combinatorial algorithm for \(K_k\) -detection requires \(n^{k-o(1)}\) time. This lower bound of \(m^{2-1/\lceil k/2 \rceil - o(1)}\) coincides with the runtime in (1), showing that the algorithms of [4, 22, 37], as well as our combinatorial algorithm for directed-cycle detection given in Section 7, are optimal (for combinatorial algorithms). The same applies to the algorithm given by Part (ii) of Theorem 1.
Paper Overview:. The goal of Section 2 is to introduce the definitions we will use in subsequent sections. Section 3 is devoted to proving Theorem 5. Theorem 1 is proved in Sections 4 and 5: the former deals with Part (ii) of the theorem and the latter with Part (i). Section 6 contains the proofs of Theorems 2 and 4. Finally, in Section 7 we apply our methods to obtain combinatorial algorithms for counting \(C_k\) -homomorphisms and for \(C_k\) -detection in general graphs (both directed and undirected).
2 Preliminaries
Here we introduce the basic definitions to be used throughout the paper. Recall that for (undirected) graphs \(G,H\) , a homomorphism from \(H\) to \(G\) is a map \(\varphi : V(H) \rightarrow V(G)\) such that \(\lbrace \varphi (u),\varphi (v)\rbrace \in E(G)\) whenever \(\lbrace u,v\rbrace \in E(H)\) . Similarly, for digraphs \(\vec{G},\vec{H}\) , a homomorphism from \(\vec{H}\) to \(\vec{G}\) is a map \(\varphi : V(\vec{H}) \rightarrow V(\vec{G})\) such that \((\varphi (u),\varphi (v)) \in E(\vec{G})\) whenever \((u,v) \in E(\vec{H})\) . We will consider (di)graphs with edge weights. Let us define what we mean by the weight of a homomorphism.
For digraphs \(\vec{G},\vec{H}\) , denote by \(\text{Hom}(\vec{H}, \vec{G})\) the set of all homomorphisms from \(\vec{H}\) to \(\vec{G}\) . For a weight-function \(w_{\vec{G}}\) on the edges of \(\vec{G}\) , define the weighted homomorphism count as follows:
As mentioned above, we denote by \({\rm\small W-HOM-CNT}_{\vec{H}}\) the problem of computing \(\hom (\vec{H}, \vec{G}, w_{\vec{G}})\) for a given weighted input digraph \(\vec{G}\) . (Usual — i.e., unweighted — homomorphism counts can be cast in this setting by letting all edge-weights be 1.)
Finally, we recall the notion of subdivision for directed graphs:
3 Homomorphism Counting and Graph Subdivisions
In this section we prove Theorem 5, showing that counting (weighted) homomorphisms of a directed graph is at least as hard as counting homomorphisms of its directed subdivisions. The main tool in the proof is (a digraph variant of) an extremely useful result of Curticapean, Dell, and Marx [12], stated below as Lemma 3.1. This lemma deals with computing linear combinations of homomorphism counts. For digraphs \(\vec{H_1}, \dots , \vec{H_k}\) and non-zero constants \(c_1, \dots , c_k\) , let \({\rm\small HOM-CNT}_{c_1 \vec{H_1} + \dots + c_k \vec{H_k}}\) be the problem of computing \(c_1 \cdot \hom (\vec{H_1},\vec{G}) + \dots + c_k \cdot \hom (\vec{H_k},\vec{G})\) for an input digraph \(\vec{G}\) . Lemma 3.1 states that solving \({\rm\small HOM-CNT}_{c_1 \vec{H_1} + \dots + c_k \vec{H_k}}\) is essentially equivalent to solving \({\rm\small HOM-CNT}_{\vec{H_i}}\) for all \(1 \le i \le k\) .
The undirected version of Lemma 3.1 was proved in [12], and subsequently used in [6] to study homomorphism-counting in degenerate graphs. The proof uses tensor products and a result of Erdős, Lovász, and Spencer [17] regarding linear independence of homomorphism counts. Since the proof of the directed variant (namely, Lemma 3.1) is essentially the same as that of the undirected one, we postpone it to the appendix.
4 Counting Homomorphisms of Cycles: A Combinatorial Algorithm
In this section we prove the second part of Theorem 1. We prefer to prove this part first as it is technically simpler than the first part. Let \(P_r\) denote the oriented path with vertices \(1,\dots ,2r+1\) (so \(e(P_r) = 2r\) ), and where the vertices \(1, 3,\ldots ,2r+1\) are sinks and the vertices \(2, 4,\ldots ,2r\) are sources.
Let \(\vec{C}_{2\ell }\) denote the alternating orientation of \(C_{2\ell }\) .
5 Counting Homomorphisms of Cycles: Using Matrix Multiplication
In this section we prove the first part of Theorem 1. We begin with describing an algorithm for counting weighted homomorphisms of alternating orientations of cycles. As mentioned in the introduction, our algorithm is inspired by the algorithm of Yuster and Zwick [38] for finding a directed \(k\) -cycle in a (general) directed graph but bears several significant differences and tweaks. As in [38], our approach for enumerating (weighted) homomorphisms is by classifying them into a polylogarithmic number of classes, according to the in-degrees of the images of the (sink) vertices of the \(\vec{C}_{2k}\) (the alternating orientation of \(C_{2k}\) ).
6 Counting Cycle Homomorphisms Vs. Directed-cycle Detection
In this section we prove Theorems 2 and 4 as they bear some similarity. An important ingredient in the proof of Theorem 2 is the fact that the number of cycle transversals in partite graphs can be computed efficiently using an inclusion-exclusion procedure. To make this statement precise we need the following definition.
A family of graphs \({\mathcal {F}}\) is subgraph-closed if \(G \in {\mathcal {F}}\) implies that every subgraph of \(G\) is also in \({\mathcal {F}}\) . For example, \(d\) -degenerate graphs are subgraph-closed.
7 A Combinatorial Algorithm for Counting Cycle Homomorphisms in General Graphs
As our final result, we use our methods to obtain a combinatorial algorithm for counting the number of \(C_k\) -homomorphisms in a (general) directed or undirected graph with \(m\) edges in \(\tilde{O}(m^{2-1/\lceil k/2 \rceil })\) time:
In the directed case, the \(C_k\) above denotes the directed \(k\) -cycle.
It should be pointed out that, as in the proof of Theorem 4, we can use Theorem 8 to obtain an algorithm which detects if a directed or undirected graph has a \(C_k\) in \(\tilde{O}(m^{2-1/\lceil k/2 \rceil })\) time. The proof in the directed setting is particularly simple: given a digraph \(\vec{G}\) , we randomly partition its vertices into sets \(V_1,\dots ,V_k\) and only keep the edges going from \(V_i\) to \(V_{i+1}\) (for some \(1 \le i \le k)\) , denoting the resulting subdigraph by \(\vec{G}^{\prime }\) . If \(\vec{G}\) contains a \(C_k\) then with constant positive probability so does \(\vec{G}^{\prime }\) . Moreover, every \(C_k\) -homomorphism in \(\vec{G}^{\prime }\) corresponds to a proper copy of \(C_k\) , so computing \(\hom (C_k,\vec{G}^{\prime })\) suffices in order to decide if \(\vec{G}^{\prime }\) contains a \(C_k\) . Again, this can be derandomized at the cost of increasing the runtime by a logarithmic factor.
The proof of Theorem 8 is similar to that of Theorem 6. To keep the presentation simple, we focus on undirected graphs; the proof for digraphs is similar. Let \(P_r\) denote the path with \(r+1\) vertices \(1,\dots ,r+1\) (so \(P_r\) has \(r\) edges).
Footnotes
1
In fact, they only conjectured the value of \(c_k\) when \(k\) is odd; for even \(k\) it was not even clear what the “right” conjecture should be.
2
As in [14], the value of \(c_k\) in (2) assumes, for simplicity, that rectangular matrix multiplication is simulated by square matrix multiplication; the exact definition of \(c_k\) is given in (9). If \(\omega \gt 2\) and the fastest known rectangular matrix multiplication algorithms are used, \(c_k\) results in a marginal improvement over the value in (2).
3
When \(k\) is odd and \(\omega \gt \frac{2k}{k-1}\) , one can prove that \(c_k \le 2-\frac{2}{k+1} \lt \frac{(k+1)\omega }{2\omega + k-1}\) , which matches the runtime of the fastest combinatorial algorithm.
4
We note that counting copies of cycles remains \(\#W[1]\) -hard even in bounded-degeneracy graphs. This follows from the fact that counting \(k\) -cycles in general graphs can be reduced to counting \(2k\) -cycles in 2-degenerate ones via the reduction which replaces each edge of the input graph by a path of length 2 (thus producing a 2-degenerate graph).
5
We note that degeneracy is closely related to another well-studied graph parameter, namely arboricity, which is the minimum number of forests into which the edge-set of a graph can be partitioned. It is well-known that the arboricity of a \(d\) -degenerate graph is between \((d+1)/2\) and \(d\) .
6
Bressan’s result in its full generality states that for every graph \(H\) , one can count \(H\) -homomorphisms in bounded-degeneracy graphs in time \(\tilde{O}(n^{\tau (H)})\) , where \(\tau (H)\) is a suitable width parameter called DAG treewidth.
7
The “only if” direction of this result is under a certain standard hardness assumption from fine-grained complexity [1]. The proof of this direction actually shows that if \(H\) contains an induced \(\ell\) -cycle for some \(\ell \ge 6\) , then one cannot count \(H\) -homomorphisms in bounded-degeneracy graphs in time \(O(n^{1+\gamma })\) , where \(\gamma \gt 0\) is some fixed constant.
8
A degeneracy ordering of a graph can be found in time linear in its number of edges [26]. In particular, since a bounded-degeneracy graph has \(O(n)\) edges, a degeneracy ordering of such a graph can be found in time \(O(n)\) .
9
Indeed, one can observe that if the number of sources in \(\vec{H}\) is \(p \gt 1\) , then \(\vec{H}\) is a directed subdivision of the alternating orientation of \(C_{2p}\) . If \(p = 1,\) then we can think of \(C_{\ell }\) as the subdivision of the 2-vertex alternating cycle \(C_2\) , which is the multigraph with two vertices \(x,y\) and two parallel edges from \(x\) to \(y\) . Theorem 5 applies to \(\vec{H} = C_2\) as well. A different way to handle the case \(p = 1\) is to observe that in this case one can easily count homomorphisms of \(\vec{H}\) in linear time [10].
10
Here, and in what follows, by degenerate digraphs we mean digraphs where all out-degrees are bounded.
11
This is because after choosing the image of the unique source of \(\vec{H}\) (under a homomorphism from \(\vec{H}\) to \(\vec{G}\) ), there are \(O(1)\) choices for every other vertex of \(\vec{H}\) , as all vertices of \(\vec{H}\) are reachable from the source and \(\vec{G}\) has bounded out-degrees.
12
One way to do it is as follows. For every entry \((y,x)\) in the sparse representation of \(B^d_{j,i}\) , store its value in a hash table, with \((y,x)\) being the key. Then, go over all entries \((x,y)\) in the sparse representation of \(B^d_{i,j}\) , and check whether the key \((y,x)\) is in the hash table. If so, accumulate the product of the two entries.
13
The definition of \(c_k\) in [14] (which corresponds to the one of Yuster and Zwick) has an additional component (which comes from a certain combinatorial procedure, that is not applicable to our algorithm). More specifically, it is defined as \(c_k = \max _{d=(d_0, \dots , d_{k-1})} \min \left\lbrace \min _{0 \le i \le k-1} (2-d_i), C_k(d_0, \dots , d_{k-1}) \right\rbrace\) . Seemingly, this definition is not equivalent to ours, and (possibly) gives a better running time. However, this is not the case. In particular, the upper bounds on \(c_k\) (as defined in [14]) are obtained by attaining upper bounds on \(C_k\) . Specifically, it is shown in [14], that for odd \(k\) and arbitrary \(d_0, \dots , d_{k-1}\) , \(C_k(d_0, \dots , d_{k-1}) \le \frac{(k+1)\omega }{2\omega +k-1}\) , and, for \(\omega \le \frac{2k}{k-1}\) , a specific sequence \(d=(d_0, \dots , d_{k-1})\) is presented such that \(\min _{0 \le i \le k-1} (2-d_i) \ge C_k(d_0, \dots , d_{k-1}) = \frac{(k+1)\omega }{2\omega +k-1}\) (see Section 5.4 in [14]); and for even \(k\) and arbitrary \(d_0, \dots , d_{k-1}\) , \(C_k(d_0, \dots , d_{k-1}) \le \frac{k\omega - \frac{4}{k}}{2\omega + k-2-\frac{4}{k}}\) , and, for \(\omega = 2\) , a specific sequence \(d=(d_0, \dots , d_{k-1})\) is presented such that \(\min _{0 \le i \le k-1} (2-d_i) \ge C_k(d_0, \dots , d_{k-1}) = \frac{k\omega - \frac{4}{k}}{2\omega + k-2-\frac{4}{k}}\) (see Section 5.6 in [14]). Therefore, as the minimum between \(\min _{0 \le i \le k-1} (2-d_i)\) and \(C_k(d_0, \dots , d_{k-1})\) is chosen, we conclude that the expression in our definition of \(c_k\) is, in fact, equal to the one presented in [14].
The proof of Lemma 3.1 uses the notion of tensor product of digraphs, which we now recall.
A key property of the directed tensor product is that the parameter \(\hom (\vec{H},\cdot)\) is multiplicative with respect to it (for any digraph \(\vec{H}\) ). That is, for every pair of directed graphs \(\vec{G_1}, \vec{G_2}\) , it holds that
To see that (10) holds, simply observe that for functions \(\varphi _i : V(\vec{H}) \rightarrow V(\vec{G_i})\) (where \(i \in \lbrace 1,2\rbrace\) ), the function \(v \mapsto (\varphi _1(v),\varphi _2(v))\) is a homomorphism from \(\vec{H}\) to \(\vec{G_1} \times \vec{G_2}\) if and only if \(\varphi _i\) is a homomorphism from \(\vec{H}\) to \(\vec{G_i}\) for each \(i \in \lbrace 1,2\rbrace\) .
We will also need the following (trivial) observation regarding tensor products and degeneracy.
The last ingredient in the proof of Lemma 3.1 is the following directed version of a lemma of Erdős, Lovász, and Spencer [17] (see also Proposition 5.44(b) in [24]). For completeness, we give its proof at the end of this appendix (this proof is essentially identical to the undirected case).
References
[1]
A. Abboud and V. Vassilevska Williams. 2014. Popular conjectures imply strong lower bounds for dynamic problems. In Proc. 55th Annual IEEE Symposium on Foundations of Computer Science.
J. Alman and V. Vassilevska Williams. A refined laser method and faster matrix multiplication. In Proceedings of the 2021 ACM-SIAM Symposium on Discrete Algorithms (SODA). Society for Industrial and Applied Mathematics, 522–539.
S. K. Bera, L. Gishboliner, Y. Levanzov, C. Seshadhri, and A. Shapira. 2022. Counting subgraphs in degenerate graphs. ACM Journal of the ACM (JACM) 69, 3 (2022), 1–21.
S. K. Bera, N. Pashanasangi, and C. Seshadhri. Linear time subgraph counting, graph degeneracy, and the chasm at size six. In Proceedings of the 11th Innovations in Theoretical Computer Science Conference (ITCS’20). 38:1–38:20.
S. K. Bera, N. Pashanasangi, and C. Seshadhri. Near-linear time homomorphism counting in bounded degeneracy graphs: the barrier of long induced cycles. In Proceedings of the 2021 ACM-SIAM Symposium on Discrete Algorithms (SODA). Society for Industrial and Applied Mathematics, 2315–2332.
R. Curticapean, H. Dell, and D. Marx. 2017. Homomorphisms are a good basis for counting small subgraphs. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing. 210–223.
R. Curticapean and D. Marx. 2014. Complexity of counting subgraphs: Only the boundedness of the vertex-cover number counts. In Proc. 55th Annual IEEE Symposium on Foundations of Computer Science. 130–139.
M. Dalirrooyfard, T. D. Vuong, and V. Vassilevska Williams. 2019. Graph pattern detection: Hardness for all induced patterns and faster non-induced cycles. In Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing. 1167–1178.
V. Dalmau and P. Jonsson. 2004. The complexity of counting homomorphisms seen from the other side. Theoretical Computer Science 329, 1–3 (2004), 315–323.
J. Flum and M. Grohe. 2002. The parameterized complexity of counting problems. In Proc. 43rd IEEE Symposium on Foundations of Computer Science. 538–547.
M. Grohe. 2007. The complexity of homomorphism and constraint satisfaction problems seen from the other side. Journal of the ACM (JACM) 54, 1 (2007), 1–24.
A. Lincoln, V. Vassilevska Williams, and R. Williams. 2018. Tight hardness for shortest cycles and paths in sparse graphs. In Proceedings of the Twenty-Ninth Annual ACM-SIAM Symposium on Discrete Algorithms. 1236–1252
F. Le Gall. 2014. Powers of tensors and fast matrix multiplication. In International Symposium on Symbolic and Algebraic Computation (ISSAC’14). 296–303
D. W. Matula and L. L. Beck. 1983. Smallest-last ordering and clustering and graph coloring algorithms. Journal of the ACM (JACM) 30, 3 (1983), 417–427.
R. Milo, S. Shen-Orr, S. Itzkovitz, N. Kashtan, D. Chklovskii, and U. Alon. 2002. Network motifs: Simple building blocks of complex networks. Science 298, 5594 (2002), 824–827.
V. Vassilevska Williams. 2012. Multiplying matrices faster than Coppersmith-Winograd. In Proceedings of the 44th Symposium on Theory of Computing Conference (STOC). 887–898.
V. Vassilevska Williams and R. Williams. 2009. Finding, minimizing, and counting weighted subgraphs. In Proc. 41st Annual ACM Symposium on the Theory of Computing. 455–464.
V. Vassilevska Williams, R. Williams, and R. Yuster. 2010. Finding heaviest \(H\) -subgraphs in real weighted graphs, with applications. ACM Transactions on Algorithms (TALG) 6, 3 (2010), 1–23.
R. Yuster and U. Zwick. 2004. Detecting short directed cycles using rectangular matrix multiplication and dynamic programming. In SODA, vol. 4. 254–260.
We consider the problem of counting the number of copies of a fixed graph H within an input graph G. This is one of the most well-studied algorithmic graph problems, with many theoretical and practical applications. We focus on solving this problem when ...
A graph G is k-degenerate if every subgraph of G has a vertex of degree at most k. It is known that every planar graph of girth 6 (equivalently, without 3-, 4-, and 5-cycles) is 2-degenerate. On the other hand, there exist planar ...
A graph G is equimatchable if each matching in G is a subset of a maximum-size matching and it is factor critical if G-v has a perfect matching for each vertex v of G. It is known that any 2-connected equimatchable graph is either bipartite or factor ...
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].