The Complexity of Counting Surjective Homomorphisms and Compactions
Jacob Focke, Leslie Ann Goldberg, Stanislav Zivny

TL;DR
This paper characterizes the computational complexity of counting surjective homomorphisms and compactions from an input graph to a fixed graph, extending previous work on homomorphism decision and counting problems.
Contribution
It provides the first complete complexity classifications for counting surjective homomorphisms and compactions, advancing understanding of these graph mapping problems.
Findings
Complete complexity classification for counting surjective homomorphisms.
Complete complexity classification for counting graph compactions.
Identification of a dichotomy for approximate counting in connected cases.
Abstract
A homomorphism from a graph G to a graph H is a function from the vertices of G to the vertices of H that preserves edges. A homomorphism is surjective if it uses all of the vertices of H and it is a compaction if it uses all of the vertices of H and all of the non-loop edges of H. Hell and Nesetril gave a complete characterisation of the complexity of deciding whether there is a homomorphism from an input graph G to a fixed graph H. A complete characterisation is not known for surjective homomorphisms or for compactions, though there are many interesting results. Dyer and Greenhill gave a complete characterisation of the complexity of counting homomorphisms from an input graph G to a fixed graph H. In this paper, we give a complete characterisation of the complexity of counting surjective homomorphisms from an input graph G to a fixed graph H and we also give a completeâŠ
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
The Complexity of Counting Surjective Homomorphisms and Compactions
Jacob Focke, Leslie Ann Goldberg and Stanislav ĆœivnĂœ
To appear in SIDMA. A short version of this paper (without the proofs) appeared in the proceedings of SODA 2018 [14]. The research leading to these results has received funding from the European Research Council under the European Unionâs Seventh Framework Programme (FP7/2007-2013) ERC grant agreement no. 334828 and under the European Unionâs Horizon 2020 research and innovation programme (grant agreement No 714532). Jacob Focke has received funding from the Engineering and Physical Sciences Research Council (grant ref: EP/M508111/1). Stanislav ĆœivnĂœÂ was supported by a Royal Society University Research Fellowship. The paper reflects only the authorsâ views and not the views of the ERC or the European Commission. The European Union is not liable for any use that may be made of the information contained therein.
(9 April 2019)
Abstract
A homomorphism from a graph to a graph is a function from the vertices of to the vertices of that preserves edges. A homomorphism is surjective if it uses all of the vertices of and it is a compaction if it uses all of the vertices of and all of the non-loop edges of . Hell and NeĆĄetĆil gave a complete characterisation of the complexity of deciding whether there is a homomorphism from an input graph to a fixed graph . A complete characterisation is not known for surjective homomorphisms or for compactions, though there are many interesting results. Dyer and Greenhill gave a complete characterisation of the complexity of counting homomorphisms from an input graph to a fixed graph . In this paper, we give a complete characterisation of the complexity of counting surjective homomorphisms from an input graph to a fixed graph and we also give a complete characterisation of the complexity of counting compactions from an input graph to a fixed graph . In an addendum we use our characterisations to point out a dichotomy for the complexity of the respective approximate counting problems (in the connected case).
1 Introduction
A homomorphism from a graph to a graph is a function from to that preserves edges. That is, the function maps every edge of to an edge of . Many structures in graphs, such as proper colourings, independent sets, and generalisations of these, can be represented as homomorphisms, so the study of graph homomorphisms has a long history in combinatorics [2, 4, 20, 21, 24, 26].
Much of the work on this problem is algorithmic in nature. A very important early work is Hell and NeĆĄetĆilâs paper [22], which gives a complete characterisation of the complexity of the following decision problem, parameterised by a fixed graph : âGiven an input graph , determine whether there is a homomorphism from to .â Hell and NeĆĄetĆil showed that this problem can be solved in polynomial time if has a loop or is loop-free and bipartite. They showed that it is NP-complete otherwise. An important generalisation of the homomorphism decision problem is the list-homomorphism decision problem. Here, in addition to the graph , the input specifies, for each vertex of , a list of permissible vertices of . The problem is to determine whether there is a homomorphism from to that maps each vertex of to a vertex in . Feder, Hell and Huang [12] gave a complete characterisation of the complexity of this problem. This problem can be solved in polynomial time if is a so-called bi-arc graph, and it is NP-complete otherwise.
More recent work has restricted attention to homomorphisms with certain properties. A function from to is surjective if every element of is the image of at least one element of . So a homomorphism from to is surjective if every vertex of is âusedâ by the homomorphism. There is still no complete characterisation of the complexity of determining whether there is a surjective homomorphism from an input graph to a graph , despite an impressive collection of results [1, 17, 18, 19, 27]. A homomorphism from to is a compaction if it uses every vertex of and also every non-loop edge of (so it is surjective both on and on the non-loop edges in ). Compactions have been studied under the name âhomomorphic imageâ [20, 24] and even under the name âsurjective homomorphismâ [6, 26]. Once again, despite much work [1, 30, 31, 32, 33, 34], there is still no characterisation of the complexity of determining whether there is a compaction from an input graph to a graph .
Dyer and Greenhill [10] initiated the algorithmic study of counting homomorphisms. They gave a complete characterisation of the graph homomorphism counting problem, parameterised by a fixed graph : âGiven an input graph , determine how many homomorphisms there are from to .â Dyer and Greenhill showed that this problem can be solved in polynomial time if every component of is a clique with all loops present or a biclique (complete bipartite graph) with no loops present. Otherwise, the counting problem is -complete. DĂaz, Serna and Thilikos [8] and Hell and NeĆĄetĆil [23] have shown that the same dichotomy characterisation holds for the problem of counting list homomorphisms.
The main contribution of this paper is to give complete dichotomy characterisations for the problems of counting compactions and surjective homomorphisms. Our main theorem, Theorem 2, shows that the characterisation for compactions is different from the characterisation for counting homomorphisms. If every component of is (i) a star with no loops present, (ii) a single vertex with a loop, or (iii) a single edge with two loops then counting compactions to is solvable in polynomial time. Otherwise, it is -complete. We also obtain the same dichotomy for the problem of counting list compactions. Thus, even though the decision problem is still open for compactions, our theorem gives a complete classification of the complexity of the corresponding counting problem.
There is evidence that computational problems involving surjective homomorphisms are more difficult than those involving (unrestricted) homomorphisms. For example, suppose that consists of a 3-vertex clique with no loops together with a single looped vertex. As [1] noted, the problem of deciding whether there is a homomorphism from a loop-free input graph to is trivial (the answer is yes, since all vertices of may be mapped to the loop) but the problem of determining whether there is a surjective homomorphism from a loop-free input graph to is NP-complete. (To see this, recall the NP-hard problem of determining whether a connected loop-free graph that is not bipartite is -colourable. Given such a graph , we may determine whether it is 3-colourable by letting consist of the disjoint union of and a loop-free clique of size , and then checking whether there is a surjective homomorphism from to .) There is also evidence that counting problems involving surjective homomorphisms are more difficult than those involving unrestricted homomorphisms. In Section 4.3 we consider a uniform homomorphism-counting problem where all connected components of are cliques without loops and all connected components of are cliques with loops, but both and are part of the input. It turns out (Theorem 31) that in this uniform case, counting homomorphisms is in but counting surjective homomorphisms is -complete. Despite this evidence, we show (Theorem 3) that the problem of counting surjective homomorphisms to a fixed graph has the same complexity characterisation as the problem of counting all homomorphisms to : The problem is solvable in polynomial time if every component of is a clique with loops or a biclique without loops. Otherwise, it is -complete. Once again, our dichotomy characterisation extends to the problem of counting surjective list homomorphisms. Even though the decision problem is still open for surjective homomorphisms, our theorem gives a complete complexity classification of the corresponding counting problem.
In Section 1.2 we will introduce one more related counting problem â the problem of counting retractions. Informally, if is a graph containing an induced copy of then a retraction from to is a homomorphism from to that maps the induced copy to itself. Retractions are well-studied in combinatorics, often from an algorithmic perspective [1, 11, 12, 13, 31, 33]. A complexity classification is not known for the decision problem (determining whether there is a retraction from an input to ). Nevertheless, it is easy to give a complexity characterisation for the corresponding counting problem (Corollary 7). This characterisation, together with our main results, implies that a long-standing conjecture of Winkler about the complexity of the decision problems for compactions and retractions is false in the counting setting. See Section 1.2 for details.
Finally, in an addendum to this work, we address the relaxed versions of the counting problems where the goal is to approximately count surjective homomorphisms, compactions and retractions. We use our theorems to give a complexity dichotomy in the connected case for all three of these problems.
1.1 Notation and Theorem Statements
In this paper graphs are undirected and may contain loops. A homomorphism from a graph to a graph is a function such that, for all , the image is in . We use {N\bigl{(}G\rightarrow H\bigr{)}} to denote the number of homomorphisms from to . A homomorphism is said to âuseâ a vertex if there is a vertex such that . It is surjective if it uses every vertex of . We use {N^{\text{sur}}\bigl{(}G\rightarrow H\bigr{)}} to denote the number of surjective homomorphisms from to . A homomorphism is said to use an edge if there is an edge such that and . It is a compaction if it uses every vertex of and every non-loop edge of . We use {N^{\text{comp}}\bigl{(}G\rightarrow H\bigr{)}} to denote the number of compactions from to . is said to be reflexive if every vertex has a loop. It is said to be irreflexive if no vertex has a loop. We study the following computational problems111The reason that the input graph is restricted to be irreflexive in these problems, but that is not restricted, is that this is the convention in the literature. Since our results will be complexity classifications, parameterised by , we strengthen the results by avoiding restrictions on . Different conventions are possible regarding , but hardness results are typically the most difficult part of the complexity classifications in this area, so restricting leads to technically-stronger results., which are parameterised by a graph .
[TABLE]
A list homomorphism generalises a homomorphism in the same way that a list colouring of a graph generalises a (proper) colouring. Suppose that is an irreflexive graph and that is a graph. Consider a collection of sets A list homomorphism from to is a homomorphism from to such that, for every vertex of , . The set is referred to as a âlistâ, specifying the allowable targets of vertex . We use {N\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}} to denote the number of list homomorphisms from to , {N^{\text{sur}}\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}} to denote the number of surjective list homomorphisms from to and {N^{\text{comp}}\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}} to denote the number of list homomorphisms from to that are compactions. We study the following additional computational problems, again parameterised by a graph .
[TABLE]
In order to state our theorems, we define some classes of graphs. A graph is a clique if, for every pair of distinct vertices, contains the edge . (Like other graphs, cliques may contain loops but not all loops need to be present.) is a biclique if it is bipartite (disregarding any loops) and there is a partition of into two disjoint sets and such that, for every and , contains the edge . A biclique is a star if or (or both). Note that a star may have only one vertex since, for example, we could have and . We sometimes use the notation to denote an irreflexive biclique whose vertices can be partitioned into and with and . The size of a graph is the number of vertices that it has. We can now state the theorem of Dyer and Greenhill [10], as extended to list homomorphisms by DĂaz, Serna and Thilikos [8] and Hell and NeĆĄetĆil [23].
Theorem 1** (Dyer, Greenhill).**
Let be a graph. If every connected component of is a reflexive clique or an irreflexive biclique, then #Hom and #LHom are in . Otherwise, #Hom and #LHom are -complete.
We can also state the main results of this paper.
Theorem 2**.**
Let be a graph. If every connected component of is an irreflexive star or a reflexive clique of size at most then #Comp and #LComp are in . Otherwise, #Comp and #LComp are -complete.
Theorem 3**.**
Let be a graph. If every connected component of is a reflexive clique or an irreflexive biclique, then #SHom and #LSHom are in . Otherwise, #SHom and #LSHom are -complete.
The tractability results in Theorem 2 follow from the fact that the number of compactions from a graph to a graph can be expressed as a linear combination of the number of homomorphisms from to certain subgraphs of , see Section 3.1. A proof sketch of the intractability result in Theorem 2 is given at the beginning of Section 3.2. Theorem 3 is simpler, see Section 4.
1.2 Reductions and Retractions
In the context of two computational problems and , we write if there exists a polynomial-time Turing reduction from to . If there exist such reductions in both directions, we write . Theorems 1, 2 and 3 imply the following observation.
Observation 4**.**
Let be a graph. Then
[TABLE]
In order to see how Observation 4 contrasts with the situation concerning decision problems, it is useful to define decision versions of the computational problems that we study. Thus, Hom is the problem of determining whether {N\bigl{(}G\rightarrow H\bigr{)}}=0, given an input of #Hom. The decision problems Comp, SHom and LHom are defined similarly.
It is also useful to define the notion of a retraction. Suppose that is a graph with and that is an irreflexive graph. We say that a tuple of distinct vertices of induces a copy of if, for every , . A retraction from to is a homomorphism from to such that, for all , . We use {N^{\text{ret}}\bigl{(}(G;u_{1},\ldots,u_{c})\rightarrow H\bigr{)}} to denote the number of retractions from to . We briefly consider the retraction counting and decision problems, which are parameterised by a graph with .222Once again, some works would allow to have loops, and would insist that loops are preserved in the induced copy of . We prefer to stick with the convention that is irreflexive, but this does not make a difference to the complexity classifications that we describe.
[TABLE]
The following observation appears as Proposition 1 of [1]. The proposition is stated for more general structures than graphs, but it applies equally to our setting.
Proposition 5** (Bodirsky et al.).**
Let be a graph. Then
[TABLE]
We have already mentioned the fact (pointed out by Bodirsky et al.) that if is an irreflexive -vertex clique together with a single looped vertex, then Hom is in P, but SHom is NP-complete. There are no known graphs separating SHom, Comp and Ret. Moreover, Bodirsky et al. mention a conjecture [1, Conjecture 2], attributed to Peter Winkler, that, for all graphs , Comp and Ret are polynomially Turing equivalent.
The following observation, together with our theorems, implies Corollary 8 (below), which shows that the generalisation of Winklerâs conjecture to the counting setting is false unless , since #Comp and #Ret are not polynomially Turing equivalent for all .
Observation 6**.**
Let be a graph. Then \text{\#Ret(H)}\leq\text{\#LHom(H)} and \text{\#Hom(H)}\leq\text{\#Ret(H)}
Proof.
Let . We first reduce #Ret to #LHom. Consider an input to #Ret consisting of and . For each , let be the set containing the single vertex . For each , let . Let . Then {N^{\text{ret}}\bigl{(}(G;u_{1},\ldots,u_{c})\rightarrow H\bigr{)}}={N\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}}.
We next reduce #Hom to #Ret. Let be the set of all non-loop edges of . Consider an input to #Hom. Suppose without loss of generality that is disjoint from . Let be the graph with vertex set and edge set . Then induces a copy of in and {N\bigl{(}G\rightarrow H\bigr{)}}={N^{\text{ret}}\bigl{(}(G^{\prime};v_{1},\ldots,v_{c})\rightarrow H\bigr{)}}. â
Observation 6 immediately implies the following dichotomy characterisation for the problem of counting retractions.
Corollary 7**.**
Let be a graph. If every connected component of is a reflexive clique or an irreflexive biclique, then #Ret is in . Otherwise, #Ret is -complete.
Proof.
The corollary follows immediately from Observation 6 and Theorem 1. â
Corollary 8**.**
Let be a graph. Then
[TABLE]
Furthermore, there is a graph for which #Comp and #LComp are -complete, but #Hom, #LHom, #SHom, #LSHom and #Ret are in .
Proof.
Theorems 1, 2, 3 and Corollary 7 give complexity classifications for all of the problems. The reductions in the corollary follow from three easy observations.
- âą
All problems in are trivially inter-reducible.
- âą
All -complete problems are inter-reducible.
- âą
All problems in are reducible to all -complete problems.
The separating graph can be taken to be any reflexive clique of size at least or any irreflexive biclique that is not a star. â
1.3 Related Work
This section was added after the announcement of our results (https://arxiv.org/abs/1706.08786v1), in order to draw attention to some interesting subsequent work [7, 5].
Both our tractability results and our hardness results rely on the fact (see Theorem 17) that the number of compactions from to can be expressed as a linear combination of the number of homomorphisms from to certain subgraphs of . A similar statement applies to surjective homomorphisms.
As we note in the paper, these kinds of linear combinations have been noticed in related contexts before, for example in [3, Lemma 4.2] and in [26]. We use the linear combination of Theorem 17, together with interpolation, to prove hardness. Although it is standard to restrict the input graph to be irreflexive (and this restriction makes the results stronger) the fact that is required to be irreflexive causes severe difficulties.
In fact, Dellâs note about our paper [7] shows that, if you weaken the theorem statements by allowing the input to have loops, then a simpler interpolation based on a very recent paper by Curticapean, Dell and Marx [6] can be used to make the proofs very elegant! The exact same idea, written more generally, was also discovered by Chen [5].
2 Preliminaries
It will often be technically convenient to restrict the problems that we study by requiring the input graph to be connected. In each case, we do this by adding a superscript ââ to the name of the problem. For example, the problem #HomC is defined as follows.
Name.
#HomC.
Input.
A connected irreflexive graph .
Output.
{N\bigl{(}G\rightarrow H\bigr{)}}.
It is well known and easy to see (See, e.g., [26, (5.28)]) that if is an irreflexive graph with components then {N\bigl{(}G\rightarrow H\bigr{)}}=\prod_{i\in[t]}{N\bigl{(}G_{i}\rightarrow H\bigr{)}}. Similarly, given let . Then {N\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}}=\prod_{i\in[t]}{N\bigl{(}(G_{i},\mathbf{S}_{i})\rightarrow H\bigr{)}}. Thus, Dyer and Greenhillâs theorem (Theorem 1) can be re-stated in the following convenient form.
Theorem 9** (Dyer, Greenhill).**
Let be a graph. If every connected component of is a reflexive clique or an irreflexive biclique, then #HomC, #Hom, #LHomC and #LHom are all in . Otherwise, #HomC, #Hom, #LHomC and #LHom are all -complete.
Finally, we introduce some frequently used notation. For every positive integer , we define .
A subgraph of is said to be loop-hereditary with respect to if for every that is contained in a loop in , is also contained in a loop in .
We indicate that two graphs and are isomorphic by writing .
Given sets and , we write for the disjoint union of and . Given graphs and , we write for the graph . If is a set of vertices then we write as shorthand for the graph . Similarly, if is a matching (a set of disjoint edges) with vertex set , then we write as shorthand for the graph .
3 Counting Compactions
The section is divided into a short subsection on tractable cases and the main subsection on hardness results which also contains the proof of the final dichotomy result, Theorem 2.
3.1 Tractability Results
The tractability result in Lemma 10 follows from the fact (see Theorem 17) that the number of compactions from to can be expressed as a linear combination of the number of homomorphisms from to certain subgraphs of . While we need the full details of our particular linear expansion to derive our hardness results, the following simpler version suffices for tractability.
Lemma 10**.**
Let be a graph such that every connected component is an irreflexive star or a reflexive clique of size at most . Then #Comp and #LComp are in .
Proof.
First we deal with the case that is the empty graph. Suppose that is the empty graph and let be an instance of #LComp. If is empty then {N^{\text{comp}}\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}}=1. Otherwise, {N^{\text{comp}}\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}}=0. Thus, if is empty, then #LComp is in . Obviously, this also implies that #Comp is in .
Let be the set of all non-empty graphs in which every connected component is an irreflexive star or a reflexive clique of size at most . We will show that for every , #LComp is in . To do this, we need the following notation. Given a graph , let denote the sum of and the number of non-loop edges of . We will use induction on .
The base case is . In this case, has only one vertex . If is non-empty and has for every vertex then {N^{\text{comp}}\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}}=1. Otherwise, {N^{\text{comp}}\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}}=0. So #LComp is in .
For the inductive step, consider some with . Let be an instance of #LComp. If is empty then {N^{\text{comp}}\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}}=0, so suppose that is non-empty. For every subgraph of let denote the set of lists . It is easy to see that {N\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}}=\sum_{H^{\prime}}{N^{\text{comp}}\bigl{(}(G,\mathbf{S}_{H^{\prime}})\rightarrow H^{\prime}\bigr{)}}, where the sum is over all loop-hereditary subgraphs of . This observation is well known and is implicit, e.g, in the proof of a lemma of Borgs, Chayes, Kahn and Lovåsz [3, Lemma 4.2] (in a context without lists or loops).
A subgraph of is said to be a proper subgraph of if either is a strict subset of or is a strict subset of (or both). For every graph , let denote the set of non-empty proper subgraphs of that are loop-hereditary with respect to . Note that if and then and . We can refine the summation as follows.
[TABLE]
Since , every component of is a reflexive clique or an irreflexive biclique, so Theorem 1 shows that the quantity {N\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}} on the left-hand side can be computed in polynomial time. By induction, every term of the form {N^{\text{comp}}\bigl{(}(G,\mathbf{S}_{H^{\prime}})\rightarrow H^{\prime}\bigr{)}} can also be computed in polynomial time. Subtracting this from the left-hand side, we obtain {N^{\text{comp}}\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}}, as desired.
Thus, we have proved that #LComp is in . The problem #Comp is a restriction of #LComp, so it is also in .
â
3.2 Hardness Results
This is the key section of this work. In this section, we consider a graph that has a connected component that is not an irreflexive star or a reflexive clique of size at most . The objective is to show that #Comp and #LComp are -hard (this is the hardness content of Theorem 2).
We start with a brief proof sketch. The easy case is when contains a component that is not a reflexive clique or an irreflexive biclique. In this case, Dyer and Greenhillâs Theorem 1 shows that #Hom is -hard. We obtain the desired hardness by giving (in Theorem 13) a polynomial-time Turing reduction from #Hom to #Comp. The result is finished off with a trivial reduction from #Comp to #LComp. The proof of Theorem 13 is not difficult â given an input to #Hom, we add isolated vertices and edges to and recover the desired quantity {N\bigl{(}G\rightarrow H\bigr{)}} using an oracle for #Comp and polynomial interpolation. There are small technical issues related to size- components in , and these are dealt with in Lemma 11.
The more interesting case is when every component of is a reflexive clique or an irreflexive biclique, but some component is either a reflexive clique of size at least or an irreflexive biclique that is not a star. The first milestone is Lemma 23, which shows -hardness in the special case where is connected. We prove Lemma 23 in a slightly stronger setting where the input graph is connected. This allows us, in the remainder of the section, to generalise the connected case to the case in which is not connected.
The main difficulty, then, is Lemma 23. The goal is to show that #Comp is -hard when is a reflexive clique of size at least or an irreflexive biclique that is not a star. Our main method for solving this problem is a technique (Theorem 17) that lets us compute the number of compactions from a connected graph to a connected graph using a weighted sum of homomorphism counts, say {N\bigl{(}G\rightarrow J_{1}\bigr{)}},\ldots,{N\bigl{(}G\rightarrow J_{k}\bigr{)}}. An important feature is that some of the weights might be negative.
Our basic approach will be to find a constituent such that #HomC is -hard and to reduce #HomC to the problem of computing the weighted sum. Of course, if computing {N\bigl{(}G\rightarrow J_{1}\bigr{)}} is -hard and computing {N\bigl{(}G\rightarrow J_{2}\bigr{)}} is -hard, it does not follow that computing a weighted sum of these is -hard.
In order to solve this problem, in Lemmas 19 and 20 we use an argument similar to that of Lovåsz [25, Theorem 3.6] to prove the existence of input instances that help us to distinguish between the problems \text{\#Hom\textsuperscript{C}(J_{1})},\ldots,\text{\#Hom\textsuperscript{C}(J_{k})}. Theorem 21 then provides the desired reduction from a chosen #HomC to the problem of computing the weighted sum. Theorem 21 is proved by a more complicated interpolation construction, in which we use the instances from Lemma 20 to modify the input.
Having sketched the proof at a high level, we are now ready to begin. We start by working towards the proof of Theorem 13. The first step is to show that deleting size- components from does not add any complexity to #Comp.
Lemma 11**.**
Let be a graph that has exactly size- components. Let be the graph constructed from by removing all size- components. Then \text{\#Comp(H^{\prime})}\leq\text{\#Comp(H)}.
Proof.
Let be the vertices of that are contained in size- components. We can assume , otherwise . Let be an input to #Comp and note that might contain isolated vertices. For any non-negative integer , let be a set of isolated vertices, distinct from the vertices of , and let . For all , we define to be the number of homomorphisms from to with the following properties:
uses all non-loop edges of . 2. 2.
\mathopen{}\mathclose{{}\left|\sigma(V(G^{\prime}))\cap\{w_{1},\dots,w_{q}\}}\right|=i,
where is the image of under the map . We define as the number of homomorphisms from to such that . Intuitively, is the number of homomorphisms from to that use at least a set of arbitrary but fixed vertices of , as the particular choice of vertices is not important when counting homomorphisms from a set of isolated vertices. For any compaction , the restriction has to use all non-loop edges in . As does not have size- components, this implies that all vertices other than are used by . Say, additionally, that uses vertices from , for some . Then, has to use the remaining vertices. Thus, for each fixed , we obtain a linear equation:
[TABLE]
By choosing different values for the parameter we obtain a system of linear equations. Here, we choose . Then the system is of the form for
[TABLE]
Note, that the vector can be computed using #Comp oracle calls. Further,
[TABLE]
Thus, determining is sufficient for computing the sought-for {N^{\text{comp}}\bigl{(}G^{\prime}\rightarrow H^{\prime}\bigr{)}}. It remains to show that the matrix is of full rank and is therefore invertible.
If , we observe that as we cannot use at least vertices of when we have fewer than vertices in the domain. For the diagonal elements with we have that (note that ). Hence,
[TABLE]
is a triangular matrix with non-zero diagonal entries, which completes the proof. â
Lemma 12**.**
Let be a graph without any size- components. Then \text{\#Hom(H)}\leq\text{\#Comp(H)}.
Proof.
The proof is by interpolation and is somewhat similar to the proof of Lemma 11. Let be an input to #Hom. We design a graph as an input to the problem #Comp by adding a set of disjoint new edges to the graph .
We introduce some notation. Let be the set of non-loop edges of and let r=\mathopen{}\mathclose{{}\left|E^{0}(H)}\right|. Let be the number of homomorphisms from to that use exactly of the non-loop edges of (additionally, might use any number of loops). Let be a set of arbitrary but fixed non-loop edges from . We define as the number of homomorphisms from to such that are amongst the edges used by . Note that the particular choice of edges is not important when counting homomorphisms from an independent set of edges to â only depends on the numbers and .
We observe that, for each compaction , the restriction uses some set of non-loop edges and does not use any other non-loop edges of . Suppose that has cardinality \mathopen{}\mathclose{{}\left|F}\right|=r-k for some . Then uses at least the remaining fixed non-loop edges of . As does not have any size- components, this ensures at the same time that is surjective.
Therefore, we obtain the following linear equation for a fixed :
[TABLE]
As in the proof of Lemma 11, we choose to obtain a system of linear equations with
[TABLE]
We can compute using a #Comp oracle. Further,
[TABLE]
Thus, determining is sufficient for computing the sought-for number of homomorphisms {N\bigl{(}G\rightarrow H\bigr{)}}.
Finally, we show that is invertible. If , we observe that , as clearly it is impossible to use more than edges of when there are only edges in . Further, for the diagonal elements it holds that for we have as there are possibilities for assigning the edges in to the fixed set of edges of and there are vertex mappings for each such assignment of edges, also . Hence,
[TABLE]
is a triangular matrix with non-zero diagonal entries and is therefore invertible. â
Theorem 13**.**
Let be a graph. Then \text{\#Hom(H)}\leq\text{\#Comp(H)}.
Proof.
Let be the graph constructed from by removing all size- components. By Lemma 11 we obtain \text{\#Comp(H^{\prime})}\leq\text{\#Comp(H)}. Then Lemma 12 can be applied to the graph and thus we obtain \text{\#Hom(H^{\prime})}\leq\text{\#Comp(H^{\prime})}\leq\text{\#Comp(H)}. Finally, it follows from Theorem 1 that \text{\#Hom(H^{\prime})}\equiv\text{\#Hom(H)}, which gives \text{\#Hom(H)}\equiv\text{\#Hom(H^{\prime})}\leq\text{\#Comp(H^{\prime})}\leq\text{\#Comp(H)}. â
Theorem 13 shows that hardness results from Theorem 1 will carry over from #Hom to #Comp. We also know some cases where #Comp is tractable from Lemma 10. The complexity of #Comp is still unresolved if every component of is a reflexive clique or an irreflexive biclique, but some reflexive clique has size greater than , or some irreflexive biclique is not a star. This is the case described at length at the beginning of the section. Recall that the first step is to specify a technique (Theorem 17) that lets us compute the number of compactions from a connected graph to a connected graph using a weighted sum of homomorphism counts, say {N\bigl{(}G\rightarrow J_{1}\bigr{)}},\ldots,{N\bigl{(}G\rightarrow J_{k}\bigr{)}}. Towards this end, we introduce some definitions which we will use repeatedly in the remainder of this section.
Definition 14**.**
A weighted graph set is a tuple , where is a set of non-empty, pairwise non-isomorphic, connected graphs and is a function .
Definition 15**.**
Let be a connected graph. By we denote the set of non-empty, loop-hereditary, connected subgraphs of . Let be a set which contains exactly one representative of each isomorphism class of the graphs in . Finally, for , we define to be the number of graphs in that are isomorphic to .
Note that for a connected graph , we have .
Definition 16**.**
For each non-empty connected graph , we define a weight function which assigns an integer weight to each non-empty connected graph .
- âą
If is not isomorphic to any graph in , then .
- âą
If , then .
- âą
Finally, if is isomorphic to some graph in but , we define inductively as follows.
[TABLE]
Note that is well-defined as all graphs with are smaller than either in the sense of having fewer vertices or in the sense of having the same number of vertices but fewer edges.
The following theorem is the key to our approach for computing the number of compactions from a connected graph to a connected graph using a weighted sum of homomorphism counts. In the Appendix, we give an illustrative example where we verify the theorem for the case and we give the intuition behind the definitions. Here we go on to give the formal statement and proof.
Theorem 17**.**
Let be a non-empty connected graph. Then for every non-empty, irreflexive and connected graph we have {N^{\text{comp}}\bigl{(}G\rightarrow H\bigr{)}}=\sum_{J\in\mathcal{S}_{H}}\lambda_{H}(J){N\bigl{(}G\rightarrow J\bigr{)}}.
Proof.
Let be the set of non-empty connected graphs sorted by some fixed ordering that ensures that if is isomorphic to a subgraph of , then . We verify the statement of the theorem by induction over the graph index with respect to this ordering. Let be non-empty, irreflexive and connected.
For the base case, is , which is the graph with one vertex and no edges. In this case, and . Also
[TABLE]
So the theorem holds in this case.
Now assume that the statement holds for all graphs up to index and consider the graph . For ease of notation we set . We use the fact that every homomorphism from a connected graph to is a compaction onto some non-empty, loop-hereditary and connected subgraph of and vice versa. Thus, it holds that
[TABLE]
Thus, we can rearrange and use the induction hypothesis to obtain
[TABLE]
â
We remark that Theorem 17 can be generalised to graphs and with multiple connected components by looking at all subgraphs of , rather than just at the connected ones. However, within this work, the version for connected graphs suffices.
Let be a weighted graph set. The following parameterised problem is not natural in its own right, but it helps us to analyse the complexity of #CompC:
Name.
#GraphSetHomC.
Input.
An irreflexive, connected graph .
Output.
Z_{\mathcal{H},\lambda}(G)=\begin{cases}0&\quad\text{if G is empty}\\ \sum_{J\in\mathcal{H}}\lambda(J){N\bigl{(}G\rightarrow J\bigr{)}}&\quad\text{otherwise.}\end{cases}
Corollary 18**.**
Let be a non-empty connected graph. Then
[TABLE]
Proof.
The corollary follows directly from Theorem 17. â
Corollary 18 gives us the desired connection between weighted graph sets and compactions. We will use this later in the proof of Lemma 23 to establish the -hardness of #CompC when is either a reflexive clique of size at least or an irreflexive biclique that is not a star.
Our next goal is to prove Theorem 21, which states that, for certain weighted graph sets , determining is at least as hard as computing {N\bigl{(}G\rightarrow J\bigr{)}} for some graph from the set with . To this end, we first introduce two lemmas that help us to distinguish between different graphs in the interpolation that we will later use to prove Theorem 21.
For the following lemmas, we introduce some new notation. For a graph with distinguished vertex and a graph with distinguished vertex , the quantity {N\bigl{(}(G,v)\rightarrow(H,w)\bigr{)}} denotes the number of homomorphisms from to with . Analogously, {N^{\text{inj}}\bigl{(}(G,v)\rightarrow(H,w)\bigr{)}} denotes the number of injective homomorphisms from to with . If there exists an isomorphism from to that maps onto , we write , otherwise we write . In the following lemma, we show that for two such target entities and that are non-isomorphic, there exists an input which separates them. To this end, we use an argument very similar to that presented in [16, Lemma 3.6] and in the textbook by Hell and NeĆĄetĆil [24, Theorem 2.11], which goes back to the works of LovĂĄsz [25, Theorem 3.6].
Lemma 19**.**
Let and be connected graphs with distinguished vertices and such that . Suppose that one of the following cases holds:
- Case 1.
* and are reflexive graphs.*
- Case 2.
* and are irreflexive bipartite graphs, each of which contains at least one edge.*
Then
- i)
There exists a connected irreflexive graph with distinguished vertex for which {N\bigl{(}(G,v)\rightarrow(H_{1},w_{1})\bigr{)}}\neq{N\bigl{(}(G,v)\rightarrow(H_{2},w_{2})\bigr{)}}. 2. ii)
In Case 2 we can assume that contains at least one edge and is bipartite.
Proof.
In order to shorten the proof, we define some notation that depends on which case holds. In Case 1, we say that a tuple consisting of a graph with distinguished vertex is relevant if is connected and reflexive. In Case 2, we say that it is relevant if is connected, irreflexive and bipartite and contains at least one edge. We start with a claim that applies in either case.
Claim: There exists a relevant such that
[TABLE]
Proof of the claim:âTo prove the claim, assume for a contradiction that for all relevant we have
[TABLE]
The contradiction will follow from the following subclaim:
Subclaim: For every relevant , {N^{\text{inj}}\bigl{(}(G,v)\rightarrow(H_{1},w_{1})\bigr{)}}={N^{\text{inj}}\bigl{(}(G,v)\rightarrow(H_{2},w_{2})\bigr{)}}.
Proof of the subclaim:âThe proof of the subclaim is by induction on the number of vertices of . For the base case of the induction we treat the two cases separately.
In Case 1, the base case of the induction is \mathopen{}\mathclose{{}\left|V(G)}\right|=1. The relevant is the graph consisting of the single (looped) vertex . For every reflexive graph and vertex we have that {N\bigl{(}(G,v)\rightarrow(H,w)\bigr{)}}={N^{\text{inj}}\bigl{(}(G,v)\rightarrow(H,w)\bigr{)}}. Therefore, (1) implies that the subclaim is true for this .
In Case 2, the base case of the induction is \mathopen{}\mathclose{{}\left|V(G)}\right|=2. (There are no relevant with \mathopen{}\mathclose{{}\left|V(G)}\right|<2 since has to contain an edge.) Consider a relevant . Since is irreflexive and the two vertices of are connected by an edge (so cannot be mapped by a homomorphism to the same vertex of ) we have {N\bigl{(}(G,v)\rightarrow(H,w)\bigr{)}}={N^{\text{inj}}\bigl{(}(G,v)\rightarrow(H,w)\bigr{)}}. Once again, (1) implies that the subclaim is true for this .
For the inductive step, suppose that the subclaim holds for all relevant in which has up to vertices. Consider a relevant with \mathopen{}\mathclose{{}\left|V(G)}\right|=k. Let be the set of partitions of â that is, each is a set for some integer such that the elements of are non-empty and pairwise disjoint subsets of with . For with , by we denote the corresponding quotient graph, i.e. let be the graph with vertices that has an edge if and only if there exist and with . Therefore, might have loops but no multi-edges, see Figure 1. Let denote the vertex of which corresponds to the equivalence class of that contains the distinguished vertex . Finally, let denote the partition of into singletons. Then for every relevant it holds that
[TABLE]
where the third equality follows as .
Now we show that only relevant tuples actually contribute to the sum in (2). First, note that since is connected, so is .
In Case 1, every quotient graph is reflexive. Therefore, for every , the tuple is relevant.
In Case 2, is an irreflexive bipartite graph with at least one edge. Therefore, we have {N^{\text{inj}}\bigl{(}(G|_{\theta},v_{\theta})\rightarrow(H,w)\bigr{)}}>0 only if is an irreflexive bipartite graph and also, is a proper vertex-colouring of , i.e. every part of is an independent set. For such a partition , has at least one edge if does. We have now shown that only relevant tuples contribute to the sum in (2).
Therefore, let be the set of all partitions of such that is relevant. Then, we can rephrase (2) as follows.
[TABLE]
To prove the subclaim, we can set in (3) to be . Similarly, we can set it to be . Then, we can use the induction hypothesis, the subclaim, on all tuples in the sum as all these tuples are relevant and the partitions have strictly fewer than parts. Applying (1), we obtain
[TABLE]
which completes the induction and the proof of the subclaim. (End of the proof of the subclaim.)
We show next how to use the subclaim to derive a contradiction. In particular, in the subclaim we can set to be either or . This implies , which gives the desired contradiction. Thus, we have shown contrary to (1) that there exists a relevant with
[TABLE]
and therefore we have proved the claim. (End of the proof of the claim.)
In Case 2, the claim is identical to the statement of the lemma. However, in Case 1 a relevant tuple contains a reflexive graph , whereas for the statement of the lemma, has to be irreflexive. This is easily fixed as we can set to be the graph constructed from by removing all loops. Using the fact that and are reflexive, we obtain for and that
[TABLE]
Hence, the choice has all the desired properties. â
In the following lemma, we generalise the pairwise property from Lemma 19. The result and the proof are adapted versions of [15, Lemma 6]. For ease of notation let denote the set of all pairs with and .
Lemma 20**.**
Let be connected graphs with distinguished vertices where for all and, for every pair , we have . Suppose that one of the following cases holds:
- Case 1.
, is a reflexive graph.
- Case 2.
, is an irreflexive bipartite graph that contains at least one edge.
Then
- i)
There exists a connected irreflexive graph with a distinguished vertex such that, for every , it holds that {N\bigl{(}(G,v)\rightarrow(H_{i},w_{i})\bigr{)}}\neq{N\bigl{(}(G,v)\rightarrow(H_{j},w_{j})\bigr{)}}. 2. ii)
In Case 2 we can assume that contains at least one edge and is bipartite.
Proof.
Again, we use the notion of relevant tuples but slightly modify the definition from the one given in the proof of Lemma 19. A tuple is called relevant if is a connected irreflexive graph and, in Case 2, if additionally contains at least one edge and is bipartite. We show that there exists a relevant such that for every we have
[TABLE]
We use induction on , which is the number of graphs . The base case for is covered by Lemma 19. Now let us assume that the statement holds for and the inductive step is for . By the inductive hypothesis there exists a relevant such that without loss of generality (possibly by renaming the graphs )
[TABLE]
Let be an index with
[TABLE]
If no such index exists, we can simply choose the graph which then fulfils the statement of the lemma. Using the base case, there exists a relevant such that
[TABLE]
possibly renaming and . Let .
First, we show that for all we have {N\bigl{(}(G^{\prime},v^{\prime})\rightarrow(H_{i},w_{i})\bigr{)}}\geq 1. This is clearly true for Case 1, where has a loop. In this case, we can always map all vertices of to the single vertex .
In Case 2, as is connected and contains at least one edge, there is some such that . Since is relevant, is connected and bipartite and has at least one edge. Let be a partition of such that and and are independent sets of . There is a homomorphism from to with which maps all vertices in to and all vertices in to .
Therefore, in both cases we have shown that for all we have {N\bigl{(}(G^{\prime},v^{\prime})\rightarrow(H_{i},w_{i})\bigr{)}}\geq 1.
For a yet to be determined number we construct a graph from and by taking the graph and copies of and identifying the vertex with the copies of and call the resulting vertex , cf. Figure 2. Note that from the fact that and are relevant, it is straightforward to show that is relevant as well. Then, for any graph and it holds that
[TABLE]
The goal is to choose sufficiently large to achieve
[TABLE]
Accordingly, we define a permutation of the indices that inserts index between position and . The domain of corresponds to the new indices to which we assign the former indices. To avoid confusion, we give the function table in Table 1
Formally,
[TABLE]
Let M={N\bigl{(}(G,v)\rightarrow(H_{2},w_{2})\bigr{)}}. As {N\bigl{(}(G^{\prime},v^{\prime})\rightarrow(H_{j},w_{j})\bigr{)}}\geq 1 for all , it is well-defined to set
[TABLE]
and . Let be as defined above. For ease of notation, for , we set
[TABLE]
We want to show for all to complete the proof.
For we obtain
[TABLE]
For we have
[TABLE]
Since {N\bigl{(}(G,v)\rightarrow(H_{\sigma(j)},w_{\sigma(j)})\bigr{)}}\geq 1+{N\bigl{(}(G,v)\rightarrow(H_{\sigma(j+1)},w_{\sigma(j+1)})\bigr{)}} for we have
[TABLE]
Using for , we obtain
[TABLE]
Finally, we use that for all we have
[TABLE]
and conclude
[TABLE]
Thus, we have shown as required, which completes the proof. â
In the following theorem, we use the separating instances that we obtain from Lemma 20 for interpolation-based reductions to #GraphSetHomC.
Theorem 21**.**
Let be a weighted graph set for which one of two cases holds:
- Case 1.
All graphs in are reflexive.
- Case 2.
All graphs in are irreflexive and bipartite.
Then, for all with , it holds that \text{\#Hom\textsuperscript{C}(H)}\leq\text{\#GraphSetHom\textsuperscript{C}((\mathcal{H},\lambda))}.
Proof.
If, in Case 2, contains a graph without edges, i.e. a single-vertex graph , let be a weighted graph set constructed from by removing the and its corresponding weight . As #Hom is in we have
[TABLE]
and
[TABLE]
Therefore, for the remainder of this proof, we assume that every graph in contains at least one edge. Let be the set of graphs in that are assigned non-zero weights by . Note that all graphs in are pairwise non-isomorphic, connected and non-empty by definition of a weighted graph set. Thus, for every pair and every , we have .
Now, for each graph we collect the vertices which are in the same orbit of the automorphism group of . Formally, for each and , let be the orbit of , i.e. the set of vertices such that . Let be a set which contains exactly one representative from each such orbit. Further, for each set . Then, for each with , we have .
Let k^{\prime}=\sum_{i=1}^{k}\mathopen{}\mathclose{{}\left|W_{i}}\right| and let be an enumeration of . Then we can apply Lemma 20 to to obtain a connected irreflexive graph with distinguished such that for every and for all , we have {N\bigl{(}(J,u)\rightarrow(H_{i},w_{i})\bigr{)}}\neq{N\bigl{(}(J,u)\rightarrow(H_{j},w_{j})\bigr{)}}.
Let and suppose that and . Let be a non-empty graph which is an input to the problem #HomC. Let be an arbitrary vertex of . We use the same construction as in Figure 2 to design a graph as input to the problem #GraphSetHomC by taking copies of as well as the graph and identifying the copies of vertex with the vertex . As both and are connected, is as well. Then, using an oracle for #GraphSetHomC, we can compute with
[TABLE]
Now we collect the terms which belong to vertices in the same orbit. To this end, for and such that , we define \lambda_{w}=\mathopen{}\mathclose{{}\left|[w]}\right|\cdot\lambda(H_{i}), N_{w}(G)={N\bigl{(}(G,v)\rightarrow(H_{i},w)\bigr{)}} and N_{w}(J)={N\bigl{(}(J,u)\rightarrow(H_{i},w)\bigr{)}}. Let . Then, continuing from Equation (4):
[TABLE]
By choosing different values for the parameter â here it is sufficient to choose â we obtain a system of linear equations as follows:
[TABLE]
The vector can be computed using #GraphSetHomC oracle calls. Then
[TABLE]
Thus, determining is sufficient for computing the sought-for {N\bigl{(}G\rightarrow H_{i}\bigr{)}}. It remains to show that the matrix is of full rank and therefore invertible. This can be easily seen by dividing each column by its first entry. The division is well-defined as for we have by definition of . The columns of the resulting matrix are pairwise different by the choice of and as a consequence the resulting matrix is a Vandermonde matrix and therefore invertible. â
Next, we give a short technical lemma which follows from Definition 16 and is used in Lemma 23 to show that Theorem 21 gives hardness results for #CompC.
Lemma 22**.**
Let be a connected graph with at least one non-loop edge. Let be the graph obtained from by deleting exactly one non-loop edge (but keeping all vertices). If is connected, then .
Proof.
As is non-empty and connected, it is a valid input to and from the definition of (Definition 16) we obtain
[TABLE]
â
We now have most of the tools at hand to classify the complexity of #Comp. Tractability results come from Lemma 10. If has a component that is not a reflexive clique or an irreflexive biclique then hardness will be lifted from Dyer and Greenhillâs Theorem 1 via Theorem 13. The most difficult case is when all components of are reflexive cliques or irreflexive bicliques, but some component is not an irreflexive star or a reflexive clique of size at most .
If is connected then hardness will come from the following lemma, whose proof builds on the weighted graph set technology (Corollary 18) using Theorem 21 and Lemma 22 (using the stronger hardness result of Dyer and Greenhill, Theorem 9).
The remainder of the section generalises the connected case to the case in which is not connected.
Lemma 23**.**
If is a reflexive clique of size at least then #CompC is -hard. If is an irreflexive biclique that is not a star then #CompC is -hard.
Proof.
Suppose that is a reflexive clique of size at least or an irreflexive biclique that is not a star. Recall the definitions of , and weighted graph sets (Definitions 14, 15 and 16). Note that is a weighted graph set. Let be a graph obtained from by deleting a non-loop edge. Note that is connected and it is not a reflexive clique or an irreflexive biclique. Thus Theorem 9 states that #HomC is -complete. We will complete the proof of the Lemma by showing \text{\#Hom\textsuperscript{C}(H^{-})}\leq\text{\#Comp\textsuperscript{C}(H)}.
If is a reflexive graph then the definition of ensures that all graphs in are reflexive. If is an irreflexive bipartite graph, then the definition ensures that all graphs in are irreflexive and bipartite. Since is connected and therefore by Lemma 22, we can apply Theorem 21 to the weighted graph set with to obtain \text{\#Hom\textsuperscript{C}(H^{-})}\leq\text{\#GraphSetHom\textsuperscript{C}((\mathcal{S}{H},\lambda{H}))}. By Corollary 18, \text{\#GraphSetHom\textsuperscript{C}((\mathcal{S}{H},\lambda{H}))}\equiv\text{\#Comp\textsuperscript{C}(H)}. The lemma follows.â
We use the following two definitions in Lemmas 26 and 27 and in the proof of Theorem 2.
Definition 24**.**
Let be a graph. Suppose that every connected component that has more than vertices is an irreflexive star. Suppose further that some connected component has vertices and is not an irreflexive star. Let be the set of reflexive components of with vertices and let be the set of irreflexive non-star components of with vertices.
Definition 25**.**
Let denote the set of loops of a graph . We define the graph .
Lemma 26**.**
Let be a graph in which every component is a reflexive clique or an irreflexive biclique. If then \text{\#Comp\textsuperscript{C}(J)}\leq\text{\#Comp(H)}.
Proof.
Let be a graph in which every component is a reflexive clique or an irreflexive biclique. Let . It follows from the definition of that all elements of are reflexive cliques of some size (the same for all graphs in ).
If , the statement of the lemma is trivially true, since Lemma 10 shows that #Comp is in , so the restricted problem #CompC is also in .
Now assume . Suppose without loss of generality that . Let be a (connected) input to #CompC. For all , let be the graph constructed from by deleting the connected component . Using Definition 25 we define the (irreflexive) graph as an input to #Comp. Intuitively, to form from we replace the connected component with the graph , then we delete all loops. We will prove the following claim.
Claim: Let be a compaction from to . Then the restriction is a compaction from onto an element of .
Proof of the claim:âAs is a homomorphism, it maps each connected component of to a connected component of . As, furthermore, is a compaction and and have the same number of connected components, it follows that there exist connected components of such that for , is a compaction from onto . To prove the claim, we show that is an element of . In order to use all vertices of a graph in , i.e. a reflexive size- clique, a graph in has to have at least vertices itself. Therefore and by the construction of , an element of can only be one of the following:
- âą
a clique with vertices,
- âą
a biclique with vertices,
- âą
a star with at least vertices
- âą
or the copy of .
Since , it is easy to see that there is no compaction from a star onto a clique with vertices. In order to compact onto a reflexive clique of size , an element of also has to have at least edges. Thus, does not contain any bicliques. Finally, there are only connected components in that are -vertex cliques other than (possibly) . Therefore, has to be an element of , which proves the claim. (End of the proof of the claim.)
Using the notation from Definition 25, the claim implies
[TABLE]
We can simplify the expression (5) using the fact that all elements of are reflexive size- cliques:
[TABLE]
As {N^{\text{comp}}\bigl{(}(H\setminus J)^{0}\rightarrow H\setminus J\bigr{)}} does not depend on , it can be computed in constant time. Thus, using a single #Comp oracle call we can compute {N^{\text{comp}}\bigl{(}G\rightarrow J\bigr{)}} in polynomial time as required. â
Lemma 27**.**
Let be a graph in which every component is a reflexive clique or an irreflexive biclique. If is empty but is non-empty, then there exists a component such that \text{\#Comp\textsuperscript{C}(J)}\leq\text{\#Comp(H)}.
Proof.
The proof is similar to that of Lemma 26. For completeness, we give the details. By Definition 24 the elements of are of the form with for some fixed . As stars are excluded from , we have . Let denote the set of graphs with the maximum number of edges in . The elements of are pairwise isomorphic since the number of edges of a is and this function is strictly increasing for . For concreteness, fix and so that each is isomorphic to . Let . Take .
For all , let be the graph constructed from by deleting the connected component . Let be an input to #Comp. We will prove the following claim.
Claim: Let be a compaction from to . Then the restriction is a compaction from onto an element of .
Proof of the claim:âAs is a homomorphism, it maps each connected component of to a connected component of . As, furthermore, is a compaction and and have the same number of connected components, it follows that there exist connected components of such that for , is a compaction from onto . To prove the claim, we show that is an element of . In order to compact onto a graph in , a graph in has to have at least vertices and edges itself. By the construction of and the fact that is empty, a connected component in with at least vertices and edges can only be one of the following:
- âą
a biclique ,
- âą
a star with at least vertices and at least edges
- âą
or the copy of .
Since , it is easy to see that there is no compaction from a star onto a . Finally, there are only connected components in that are bicliques of the form other than (possibly) . Therefore, has to be an element of , which proves the claim. (End of the proof of the claim.)
Using the notation from Definition 25, the claim implies
[TABLE]
We can simplify the expression (6) using the fact that all elements of are of the form :
[TABLE]
As {N^{\text{comp}}\bigl{(}(H\setminus J)^{0}\rightarrow H\setminus J\bigr{)}} does not depend on , it can be computed in constant time. Thus, using a single #Comp oracle call we can compute {N^{\text{comp}}\bigl{(}G\rightarrow J\bigr{)}} in polynomial time as required. â
Finally, we prove the main theorem of this section, which we restate at this point.
Theorem 2.
Let be a graph. If every connected component of is an irreflexive star or a reflexive clique of size at most then #Comp and #LComp are in . Otherwise, #Comp and #LComp are -complete.
Proof.
The membership of #Comp in is straightforward. We distinguish between a number of cases depending on the graph .
Case 1: Suppose that every connected component of is an irreflexive star or a reflexive clique of size at most . Then #LComp is in by Lemma 10.
Case 2: Suppose that contains a component that is not a reflexive clique or an irreflexive biclique. Then the hardness of #Hom (from Theorem 1) together with the reduction \text{\#Hom(H)}\leq\text{\#Comp(H)} (from Theorem 13) implies that #Comp is -hard. The hardness of #LComp follows from the trivial reduction from #Comp to #LComp.
Case 3: Suppose that the components of are reflexive cliques or irreflexive bicliques and that contains at least one component that is not an irreflexive star or a reflexive clique of size at most . Every graph is a reflexive clique of size at least or an irreflexive biclique that is not a star. By Lemma 23, #CompC is -complete. Finally, as is non-empty, we can use either Lemma 26 or Lemma 27 to obtain the existence of with \text{\#Comp\textsuperscript{C}(J)}\leq\text{\#Comp(H)}. This implies that #Comp is #P-hard. As in Case 2, the hardness of #LComp follows from the trivial reduction from #Comp to #LComp. â
4 Counting Surjective Homomorphisms
The proof of Theorem 3 is divided into two sections. The first of these deals with tractable cases and the second deals with hardness results and also contains the proof of the final theorem. Taken together, Theorem 3 and Dyer and Greenhillâs Theorem 1 show that the problem of counting surjective homomorphisms to a fixed graph has the same complexity characterisation as the problem of counting all homomorphisms to .
Section 4.3 shows that this equivalence disappears in the uniform case, where is part of the input, rather than being a fixed parameter of the problem. Specifically, Theorem 31 demonstrates a setting in which counting surjective homomorphisms is more difficult than counting all homomorphisms (assuming ).
4.1 Tractability Results
Theorem 28**.**
Let be a graph. Then \text{\#LSHom(H)}\leq\text{\#LHom(H)}.
Proof.
Let be fixed and \mathopen{}\mathclose{{}\left|V(H)}\right|=q. Let be an input instance of #LSHom. Let be the vertices of in an arbitrary but fixed order. With respect to this ordering and with respect to a homomorphism from to , let us denote by the first vertex of which is assigned the first new vertex of (), the first vertex of which is assigned the second new vertex of and so on. Every surjective homomorphism from to contains exactly one subsequence and every homomorphism containing such a subsequence is surjective. The number of subsequences is bounded from above by . Let be an assignment of the vertices of to the vertices in . There are such assignments. We call a configuration of and the set of all configurations for the given . For every such configuration we create a #LHom instance with and
[TABLE]
Intuitively, we use lists to âpinâ the vertices in to the vertices assigned by and to prohibit the remainder of the vertices of from being mapped to new vertices of . Then
[TABLE]
We can compute {N^{\text{sur}}\bigl{(}(G,\mathbf{S})\rightarrow H\bigr{)}} by making a #LHom oracle call for every instance and adding the results. The number of oracle calls is bounded from above by the polynomial . â
Corollary 29**.**
Let be a graph. If every connected component of is a reflexive clique or an irreflexive biclique then #LSHom is in .
Proof.
The statement follows directly from Theorem 28 using Dyer and Greenhillâs dichotomy from Theorem 1. â
4.2 Hardness Results
The following result and proof are very similar to that of Theorem 13 and Lemma 12, respectively. For completeness, we repeat the proof in detail.
Theorem 30**.**
Let be a graph. Then \text{\#Hom(H)}\leq\text{\#SHom(H)}.
Proof.
Let \mathopen{}\mathclose{{}\left|V(H)}\right|=q and be an input to #Hom. We design a graph as an input to the problem #SHom by adding a set of new isolated vertices to the graph .
We introduce some additional notation. Let be the number of homomorphisms from to that use exactly of the vertices of . Let be a set of arbitrary but fixed vertices from . We define as the number of homomorphisms from to such that are amongst the vertices used by . The particular choice of vertices is not important when counting homomorphisms from a set of isolated verticesâ only depends on the numbers and .
We observe that, for each surjective homomorphism , the restriction uses a subset of vertices and does not use any vertices outside of . Suppose that has cardinality \mathopen{}\mathclose{{}\left|V^{\prime}}\right|=q-k for some . Then uses at least the remaining fixed vertices of .
Therefore, we obtain the following linear equation for a fixed :
[TABLE]
By choosing different values for the parameter we obtain a system of linear equations. Here, we choose . Then the system is of the form for
[TABLE]
Note, that the vector can be computed using #SHom oracle calls. Further,
[TABLE]
Thus, determining is sufficient for computing the sought-for {N\bigl{(}G\rightarrow H\bigr{)}}. It remains to show that the matrix is of full rank and is therefore invertible.
For , clearly . Further, for the diagonal elements we have for . Hence,
[TABLE]
is a triangular matrix with non-zero diagonal entries, which completes the proof. â
Theorem 3.
Let be a graph. If every connected component of is a reflexive clique or an irreflexive biclique, then #SHom and #LSHom are in . Otherwise, #SHom and #LSHom are -complete.
Proof.
The easiness result follows from Corollary 29 using the trivial reduction \text{\#SHom(H)}\leq\text{\#LSHom(H)}. The hardness result follows from the same trivial reduction, along with Theorem 30 and the dichotomy for #Hom from Theorem 1.
â
4.3 The Uniform Case
We have seen from Theorems 1 and 3 that the problem of counting homomorphisms to a fixed graph has the same complexity as the problem of counting surjective homomorphisms to .
Nevertheless, there are scenarios in which counting problems involving surjective homomorphisms are more difficult than those involving unrestricted homomorphisms. To illustrate this point, we consider the following uniform homomorphism-counting problems. Motivated by terminology from constraint satisfaction, we use âuniformâ to indicate that the target graph is part of the input, rather than being a fixed parameter.
[TABLE]
The main result of this section is the following theorem.
Theorem 31**.**
Uniform#HomToCliques* is in but Uniform#SHomToCliques is -complete.*
In order to prove Theorem 31, we define a counting variant of the subset sum problem. Given a set of integers and an integer let , be the number of subsets such that the sum of the elements in is equal to . The counting problem is stated as follows.
Name.
#SubsetSum.
Input.
A set of positive integers and a positive integer .
Output.
.
It is well known that #SubsetSum is -complete (see for instance the textbook by Papadimitriou [29, Theorems 9.9, 9.10 and 18.1]). Thus, Theorem 31 follows immediately from Lemmas 32 and 33.
Lemma 32**.**
Uniform#HomToCliques* is in .*
Proof.
Let and be an input instance of Uniform#HomToCliques. Let be the number of connected components of and let be the number of vertices of these components, respectively. Let have connected components with vertices, respectively. Then, as all components are cliques and is reflexive,
[TABLE]
Thus, it is easy to compute {N\bigl{(}G\rightarrow H\bigr{)}}. â
Lemma 33**.**
.
Proof.
Let , be an input instance of #SubsetSum. We define . Now, we design a polynomial time algorithm to determine using an oracle for Uniform#SHomToCliques. If , we have . Now assume . We create an input of Uniform#SHomToCliques as follows. We set to be an irreflexive graph with a connected component for each , where is a clique with vertices. Furthermore, we set to be a reflexive graph with two connected components and . Let be a clique with vertices and let be a clique with vertices. By we denote the Stirling number of the second kind, i.e. the number of partitions of a set of elements into non-empty subsets. By definition, we have if .
Let be a homomorphism from to and let be the number of vertices of that are mapped to the connected component . Note that has to map each connected component of to a connected component of . By the construction of , this implies that there exists a subset such that the sum of elements in is equal to . Furthermore, as all connected components of and are cliques and is reflexive, the number of surjective homomorphisms from to that assign exactly fixed vertices to is equal to the number of surjective mappings from to , which is . Therefore, we can express {N^{\text{sur}}\bigl{(}G\rightarrow H\bigr{)}} as follows.
[TABLE]
where the factor corresponds to the number surjective mappings from the remaining fixed vertices of to the component . Finally, we use the fact that the summands in (7) are non-zero only if and , which implies . Thus,
[TABLE]
â
5 Addendum: A Dichotomy for Approximately Counting Homomorphisms with Surjectivity Constraints
The following standard definitions are taken from [28, Definitions 11.1, 11.2, Exercise 11.3]. A randomised algorithm gives an -approximation for the value if the output of the algorithm satisfies . A fully polynomial randomised approximation scheme (FPRAS) for a problem is a randomised algorithm which, given an input and a parameter , outputs an -approximation to in time that is polynomial in and the size of the input . The concept of an approximation-preserving reduction (AP-reduction) between counting problems was introduced by Dyer, Goldberg, Greenhill and Jerrum [9]. We will not need the detailed definition here, but the definition has the property that if there is an AP-reduction from problem to problem (written as ) then this reduction, together with an FPRAS for , yields an FPRAS for . The problem , which is the problem of counting the independent sets of a bipartite graph, comes up frequently in approximate counting because it is complete with respect to AP-reductions in an intermediate complexity class. It is not believed to have an FPRAS. Galanis, Goldberg and Jerrum [15] gave a dichotomy for the problem of approximately counting homomorphisms in the connected case, in terms of .
Theorem 34** ([15]).**
Let be a connected graph. If is a reflexive clique or an irreflexive biclique, then there is an FPRAS for #Hom. Otherwise, \#\text{BIS}\leq_{\mathrm{AP}}\text{\#Hom(H)}.
In this addendum we give a similar dichotomy for approximately counting homomorphisms with surjectivity constraints333When is not connected, the complexity of approximate counting is open even for counting homomorphisms. Hence we do not address this case here.. The tractability part of the following theorem follows from Theorem 3, Corollary 7 and from Lemma 36 below. The -hardness follows from Theorem 34 and from the reductions in Lemmas 37, 38 and 39.
Theorem 35**.**
Let be a connected graph. If is a reflexive clique or an irreflexive biclique, then there is an FPRAS for #SHom, #Ret and #Comp. Otherwise, each of these problems is -hard under approximation-preserving reductions.
Lemma 36**.**
Let be a reflexive clique or an irreflexive biclique. Then there is an FPRAS for #Comp.
Proof.
Let be a reflexive clique or an irreflexive biclique with vertices and edges. Our goal is give an FPRAS for #Comp.
First, we show that we can assume without loss of generality that every input to #Comp has no isolated vertices. To see this, suppose instead that is of the form where is the set of isolated vertices in . As is connected, we have {N^{\text{comp}}\bigl{(}G\rightarrow H\bigr{)}}=q^{\mathopen{}\mathclose{{}\left|I}\right|}{N^{\text{comp}}\bigl{(}G^{\prime}\rightarrow H\bigr{)}}. Thus, an estimate of the number of compactions from to will immediately enable us to approximately count compactions from to .
From now on we restrict attention to inputs which have no isolated vertices. We use to denote the set of homomorphisms from to .
Case 1. is a reflexive clique.
Let be a size- input to #Comp. Then {N\bigl{(}G\rightarrow H\bigr{)}}=q^{n}. If there is a compaction from to then there is a set with and a compaction from to . Each assignment of the (at most ) vertices in extends to a compaction from to . Thus, we have {N^{\text{comp}}\bigl{(}G\rightarrow H\bigr{)}}\geq q^{n-2p}={N\bigl{(}G\rightarrow H\bigr{)}}/q^{2p}. Using this lower bound, it is straightforward to apply the naive Monte Carlo method (cf. [28, Theorem 11.1]). Hence Algorithm 1 with and gives an -approximation for the number of compactions in .
If there are no compactions in then the algorithm answers [math]. Otherwise, the number of compactions in is at least , so the algorithm gives an -approximation.
When the algorithm is run with , the running time is at most a polynomial in and because is at most a polynomial in and the basic tasks (choosing a sample from , determining whether a sample is a compaction, and computing ) can all be done in time. Thus, the algorithm gives an FPRAS for #Comp.
Case 2. is an irreflexive biclique.
Let the bipartition of be where . We can assume that , otherwise counting compactions to is trivial.
Without loss generality, we can assume that inputs to #Comp are bipartite (as well as having no isolated vertices). (If is not bipartite, then {N^{\text{comp}}\bigl{(}G\rightarrow H\bigr{)}}=0.)
Suppose that is an input to #Comp. Let be the connected components of . For each , let be a fixed bipartition of such that 1\leq\ell_{i}=\mathopen{}\mathclose{{}\left|L_{i}}\right|\leq\mathopen{}\mathclose{{}\left|R_{i}}\right|=r_{i}. Then {N\bigl{(}G\rightarrow H\bigr{)}}=\prod_{i=1}^{\kappa}\mathopen{}\mathclose{{}\left(\ell_{H}^{{\ell_{i}}}{r_{H}}^{{r_{i}}}+{\ell_{H}}^{{r_{i}}}{r_{H}}^{{\ell_{i}}}}\right)\leq 2\prod_{i=1}^{\kappa}{\ell_{H}}^{{\ell_{i}}}{r_{H}}^{{r_{i}}}.
Let be the set of functions . Given , we say that a homomorphism from to obeys if, for each , the vertices of are assigned to vertices in .
Case 2a. .
Let be the function in that maps every to . Since has no isolated vertices, each of has at least  vertices, so there is a compaction from to which obeys .
As in Case 1, there is a set of size at most such that there is a compaction from to that obeys the restriction of to . Every assignment of the vertices in that obeys yields an -obeying compaction from to . Since , we obtain the lower bound
[TABLE]
By the same arguments as in Case 1, Algorithm 1 with and gives an -approximation for the number of compactions in . When the algorithm is run with , the running time is at most a polynomial in and , so it can be used in an FPRAS for inputs with .
Case 2b. .
For each , let be the set of homomorphisms obeying , and let and be the number of homomorphisms and compactions obeying , respectively. Given a compaction that obeys we obtain a lower bound as before:
[TABLE]
Now Algorithm 1 with and gives an -approximation for the number of compactions in . Taking and summing over the functions , we obtain an -approximation for the number of compactions in . The running time of each call to Algorithm 1 is at most a polynomial in and . Thus, putting the cases together, we get an FPRAS for #Comp.â
Lemma 37**.**
Let be a graph. Then \text{\#Hom(H)}\leq_{\mathrm{AP}}\text{\#SHom(H)}.
Proof.
Let . Given any positive integer , let denote the number of surjective functions from to . Clearly, , since the range of every non-surjective function from to is a proper subset of , and there are most of these. Also, the number of functions from onto this subset is at most .
Given any -vertex input to the problem #Hom, let
[TABLE]
Clearly, , and can be computed in time . Note that
[TABLE]
Let be the graph constructed from by adding a set of isolated vertices that are distinct from the vertices in . We claim that
[TABLE]
To see this, note that any homomorphism from to , together with a surjective homomorphism from the to , constitutes a surjective homomorphism from to . Any other surjective homomorphism from to consists of a non-surjective homomorphism from to (and there are of these) together with some homomorphism from to (and there are at most of these). Dividing through by and applying our lower bound for and then inequality (8), we have
[TABLE]
Given Equation (9), the proof of [9, Theorem 3] shows that to approximate {N\bigl{(}G\rightarrow H\bigr{)}} with accuracy , we need only use the oracle to obtain an approximation for {N^{\text{sur}}\bigl{(}G_{t}\rightarrow H\bigr{)}} with accuracy . We can then return the floor of . The only remaining issue is how to compute . However, it is easy to do this in time since , where is a Stirling number of the second kind.â
Lemma 38**.**
Let be a connected graph. Then \text{\#Hom(H)}\leq_{\mathrm{AP}}\text{\#Comp(H)}.
Proof.
If not explicitly defined otherwise, we use the same notation and observations as in the proof of Lemma 37. In addition let be the number of non-loop edges in and . If is an input to #Hom of size , is the graph constructed from by adding a set of isolated edges distinct from the edges in . If is a graph of size the statement of the lemma clearly holds. If otherwise is a connected graph of size at least , every homomorphism that uses all non-loop edges of is also surjective and therefore a compaction. Thus, we obtain
[TABLE]
Dividing through by gives
[TABLE]
If we choose the remainder of this proof is analogous to that of Lemma 37. â
Lemma 39**.**
Let be a graph. Then \text{\#Hom(H)}\leq_{\mathrm{AP}}\text{\#Ret(H)}.
Proof.
Let q=\mathopen{}\mathclose{{}\left|V(H)}\right| and be an input to #Hom. Further, let be a copy of and be the vertices of ordered in such a way that they induce a copy of . Then {N\bigl{(}G\rightarrow H\bigr{)}}={N^{\text{ret}}\bigl{(}(G\oplus H^{\prime};u_{1},\ldots,u_{q})\rightarrow H\bigr{)}}. â
Appendix: Decomposition of {N^{\text{comp}}\bigl{(}G\rightarrow K_{2,3}\bigr{)}}
In this appendix, we work through a long example to illustrate some of the definitions and ideas from Section 3.2. We do this by verifying the statement of Theorem 17 for the special case where .
Of course, the theorem is already proved in the earlier sections of this paper, but we work through this example in order to help the reader gain familiarity with the definitions. For and a non-empty, irreflexive and connected graph we want to prove
[TABLE]
First, we set , cf. Figure 3, as defined in Definition 15.
Next, we recall the definitions of and from Definitions 15 and 16. For , is the number of non-empty connected subgraphs of that are isomorphic to . Also, if . If otherwise is isomorphic to some graph in but , we have
[TABLE]
In order to verify (10), we have to determine for all . As is defined inductively by (11), we first determine for all with .
We start with the graph and determine . Clearly, has only one connected subgraph and we can choose . Recall that for all graphs that are not isomorphic to any graph in , i.e. not isomorphic to in this case. By definition we have
[TABLE]
This conforms with our intuition as for the single vertex graph , it clearly holds that
[TABLE]
Thus, we have now verified (10) for .
Using this information, we consider the graph next and determine and for , see Table 3. contains two connected subgraphs that are isomorphic to , therefore . Then, from (11) we obtain
[TABLE]
Plugging this into (10) for , we get
[TABLE]
Now let us verify this expression. Recall that is connected. The central idea behind our approach is that every homomorphism from to is a compaction onto some connected subgraph of . Furthermore, tells us how many such subgraphs there are that are isomorphic to . Thus,
[TABLE]
Rearranging and using the fact that we already know {N^{\text{comp}}\bigl{(}G\rightarrow H_{10}\bigr{)}}={N\bigl{(}G\rightarrow H_{10}\bigr{)}} from (12):
[TABLE]
Thus, we have now proved (13) which in turn proves (10) for .
Using (12) and (13) we can now go on to find (see Table 4) that
[TABLE]
and so on.
This gives the intuition behind the formal definitions of and . For completeness, we give the values for all graphs through in Tables 2 through 11. From Table 11 we can conclude that for the statement of Theorem 17 gives
[TABLE]
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Manuel Bodirsky, Jan KĂĄra, and Barnaby Martin. The complexity of surjective homomorphism problems â a survey. Discrete Applied Mathematics , 160(12):1680 â 1690, 2012.
- 2[2] Christian Borgs, Jennifer Chayes, LĂĄszlĂł LovĂĄsz, Vera T. SĂłs, and Katalin Vesztergombi. Counting graph homomorphisms. In Topics in discrete mathematics , volume 26 of Algorithms Combin. , pages 315â371. Springer, Berlin, 2006.
- 3[3] Christian Borgs, Jennifer T. Chayes, Jeff Kahn, and LĂĄszlĂł LovĂĄsz. Left and right convergence of graphs with bounded degree. Random Struct. Algorithms , 42(1):1â28, 2013.
- 4[4] Graham R. Brightwell and Peter Winkler. Graph homomorphisms and phase transitions. J. Comb. Theory, Ser. B , 77(2):221â262, 1999.
- 5[5] Hubie Chen. Homomorphisms are indeed a good basis for counting: Three fixed-template dichotomy theorems, for the price of one. Co RR , abs/1710.00234, 2017.
- 6[6] Radu Curticapean, Holger Dell, and DĂĄniel Marx. Homomorphisms are a good basis for counting small subgraphs. In Proceedings of the 49th Annual ACM Symposium on Theory of Computing , pages 210â213, 2017.
- 7[7] Holger Dell. Note on âThe Complexity of Counting Surjective Homomorphisms and Compactionsâ. Co RR , abs/1710.01712, 2017.
- 8[8] Josep DĂaz, Maria Serna, and Dimitrios Thilikos. Recent results on parameterized H đ» {H} -coloring. In J. NeĆĄetĆil and P. Winkler, editors, Graphs, Morphisms and Statistical Physics , volume 63 of DIMACS Series in Discrete Mathematics and Theoretical Computer Science , 2004.
