Counting Homomorphisms to Trees Modulo a Prime

Authors Andreas Göbel, J. A. Gregor Lagodzinski, Karen Seidel

Thumbnail PDF


  • Filesize: 0.55 MB
  • 13 pages

Document Identifiers

Author Details

Andreas Göbel
  • Hasso Plattner Institute, University of Potsdam, Potsdam, Germany
J. A. Gregor Lagodzinski
  • Hasso Plattner Institute, University of Potsdam, Potsdam, Germany
Karen Seidel
  • Hasso Plattner Institute, University of Potsdam, Potsdam, Germany

Cite AsGet BibTex

Andreas Göbel, J. A. Gregor Lagodzinski, and Karen Seidel. Counting Homomorphisms to Trees Modulo a Prime. In 43rd International Symposium on Mathematical Foundations of Computer Science (MFCS 2018). Leibniz International Proceedings in Informatics (LIPIcs), Volume 117, pp. 49:1-49:13, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2018)


Many important graph theoretic notions can be encoded as counting graph homomorphism problems, such as partition functions in statistical physics, in particular independent sets and colourings. In this article we study the complexity of #_pHomsToH, the problem of counting graph homomorphisms from an input graph to a graph H modulo a prime number p. Dyer and Greenhill proved a dichotomy stating that the tractability of non-modular counting graph homomorphisms depends on the structure of the target graph. Many intractable cases in non-modular counting become tractable in modular counting due to the common phenomenon of cancellation. In subsequent studies on counting modulo 2, however, the influence of the structure of H on the tractability was shown to persist, which yields similar dichotomies. Our main result states that for every tree H and every prime p the problem #_pHomsToH is either polynomial time computable or #_pP-complete. This relates to the conjecture of Faben and Jerrum stating that this dichotomy holds for every graph H when counting modulo 2. In contrast to previous results on modular counting, the tractable cases of #_pHomsToH are essentially the same for all values of the modulo when H is a tree. To prove this result, we study the structural properties of a homomorphism. As an important interim result, our study yields a dichotomy for the problem of counting weighted independent sets in a bipartite graph modulo some prime p. These results are the first suggesting that such dichotomies hold not only for the one-bit functions of the modulo 2 case but also for the modular counting functions of all primes p.

Subject Classification

ACM Subject Classification
  • Theory of computation → Problems, reductions and completeness
  • Mathematics of computing → Graph theory
  • Mathematics of computing → Combinatorics
  • Algorithms
  • Theory
  • Graph Homomorphisms
  • Counting Modulo a Prime
  • Complexity Dichotomy


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. A. A. Bulatov and M. Grohe. The complexity of partition functions. Theoretical Computer Science, 348(2-3):148-186, 2005. URL:
  2. J.-Y. Cai, X. Chen, and P. Lu. Graph homomorphisms with complex values: A dichotomy theorem. SIAM Journal on Computing, 42(3):924-1029, 2013. URL:
  3. J.-Y. Cai and P. Lu. Holographic algorithms: From art to science. Journal of Computer and System Sciences, 77(1):41-61, 2011. Google Scholar
  4. M. E. Dyer, A. M. Frieze, and M. Jerrum. On counting independent sets in sparse graphs. SIAM Journal on Computing, 31(5):1527-1541, 2002. URL:
  5. M. E. Dyer and C. S. Greenhill. The complexity of counting graph homomorphisms. Random Structures and Algorithms, 17(3-4):260-289, 2000. Google Scholar
  6. J. Faben. The complexity of counting solutions to generalised satisfiability problems modulo k. arXiv, abs/0809.1836, 2008. Google Scholar
  7. J. Faben and M. Jerrum. The complexity of parity graph homomorphism: an initial investigation. Theory of Computing, 11:35-57, 2015. Google Scholar
  8. A. Göbel (A. Gkompel-Magkakis). Counting, Modular Counting and Graph Homomorphisms. PhD thesis, University of Oxford, 2016. Google Scholar
  9. A. Göbel, L. A. Goldberg, and D. Richerby. The complexity of counting homomorphisms to cactus graphs modulo 2. ACM Transactions on Computation Theory, 6(4):17:1-17:29, 2014. Google Scholar
  10. A. Göbel, L. A. Goldberg, and D. Richerby. Counting homomorphisms to square-free graphs, modulo 2. ACM Transactions on Computation Theory,, 8(3):12:1-12:29, 2016. Google Scholar
  11. L. A. Goldberg, M. Grohe, M. Jerrum, and M. Thurley. A complexity dichotomy for partition functions with mixed signs. SIAM Journal on Computing, 39(7):3336-3402, 2010. Google Scholar
  12. L. M. Goldschlager and I. Parberry. On the construction of parallel computers from various bases of Boolean functions. Theoretical Computer Science, 43:43-58, 1986. Google Scholar
  13. H. Guo, S. Huang, P. Lu, and M. Xia. The complexity of weighted boolean #CSP modulo k. In Symposium on Theoretical Aspects of Computer Science (STACS), pages 249-260, 2011. Google Scholar
  14. P. Hell and J. Nešetřil. On the complexity of H-coloring. Journal of Combinatorial Theory, Series B, 48(1):92-110, 1990. Google Scholar
  15. R. E. Ladner. On the structure of polynomial time reducibility. Journal of the ACM, 22(1):155-171, 1975. Google Scholar
  16. C. H. Papadimitriou and S. Zachos. Two remarks on the power of counting. In Proceedings of the GI-Conference on Theoretical Computer Science, pages 269-276, 1982. Google Scholar
  17. S. Toda. PP is as hard as the polynomial-time hierarchy. SIAM Journal on Computing, 20(5):865-877, 1991. Google Scholar
  18. L. G. Valiant. Accidental algorthims. In Proceedings of the IEEE Symposium on Foundations of Computer Science, pages 509-517, 2006. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail