Document Open Access Logo

Counting Subgraphs in Somewhere Dense Graphs

Authors Marco Bressan, Leslie Ann Goldberg, Kitty Meeks, Marc Roth

Thumbnail PDF


  • Filesize: 0.67 MB
  • 14 pages

Document Identifiers

Author Details

Marco Bressan
  • Department of Computer Science, University of Milan, Italy
Leslie Ann Goldberg
  • Department of Computer Science, University of Oxford, UK
Kitty Meeks
  • School of Computing Science, University of Glasgow, UK
Marc Roth
  • Department of Computer Science, University of Oxford, UK

Cite AsGet BibTex

Marco Bressan, Leslie Ann Goldberg, Kitty Meeks, and Marc Roth. Counting Subgraphs in Somewhere Dense Graphs. In 14th Innovations in Theoretical Computer Science Conference (ITCS 2023). Leibniz International Proceedings in Informatics (LIPIcs), Volume 251, pp. 27:1-27:14, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2023)


We study the problems of counting copies and induced copies of a small pattern graph H in a large host graph G. Recent work fully classified the complexity of those problems according to structural restrictions on the patterns H. In this work, we address the more challenging task of analysing the complexity for restricted patterns and restricted hosts. Specifically we ask which families of allowed patterns and hosts imply fixed-parameter tractability, i.e., the existence of an algorithm running in time f(H)⋅|G|^O(1) for some computable function f. Our main results present exhaustive and explicit complexity classifications for families that satisfy natural closure properties. Among others, we identify the problems of counting small matchings and independent sets in subgraph-closed graph classes 𝒢 as our central objects of study and establish the following crisp dichotomies as consequences of the Exponential Time Hypothesis: - Counting k-matchings in a graph G ∈ 𝒢 is fixed-parameter tractable if and only if 𝒢 is nowhere dense. - Counting k-independent sets in a graph G ∈ 𝒢 is fixed-parameter tractable if and only if 𝒢 is nowhere dense. Moreover, we obtain almost tight conditional lower bounds if 𝒢 is somewhere dense, i.e., not nowhere dense. These base cases of our classifications subsume a wide variety of previous results on the matching and independent set problem, such as counting k-matchings in bipartite graphs (Curticapean, Marx; FOCS 14), in F-colourable graphs (Roth, Wellnitz; SODA 20), and in degenerate graphs (Bressan, Roth; FOCS 21), as well as counting k-independent sets in bipartite graphs (Curticapean et al.; Algorithmica 19). At the same time our proofs are much simpler: using structural characterisations of somewhere dense graphs, we show that a colourful version of a recent breakthrough technique for analysing pattern counting problems (Curticapean, Dell, Marx; STOC 17) applies to any subgraph-closed somewhere dense class of graphs, yielding a unified view of our current understanding of the complexity of subgraph counting.

Subject Classification

ACM Subject Classification
  • Theory of computation → Problems, reductions and completeness
  • Mathematics of computing → Graph theory
  • counting problems
  • somewhere dense graphs
  • parameterised complexity theory


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


  1. Noga Alon, Phuong Dao, Iman Hajirasouliha, Fereydoun Hormozdiari, and S. Cenk Sahinalp. Biomolecular network motif counting and discovery by color coding. Bioinformatics, 24(13):i241-i249, 2008. URL:
  2. Noga Alon, Raphael Yuster, and Uri Zwick. Color-Coding. J. ACM, 42(4):844-856, 1995. URL:
  3. Suman K. Bera, Lior Gishboliner, Yevgeny Levanzov, C. Seshadhri, and Asaf Shapira. Counting subgraphs in degenerate graphs. J. ACM, 69(3):23:1-23:21, 2022. URL:
  4. Suman K. Bera, Noujan Pashanasangi, and C. Seshadhri. Linear time subgraph counting, graph degeneracy, and the chasm at size six. In Proceedings of the 11th conference on Innovations in Theoretical Computer Science (ITCS), pages 38:1-38:20. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2020. URL:
  5. Suman K. Bera, Noujan 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), pages 2315-2332. SIAM, 2021. URL:
  6. Édouard Bonnet, Eun Jung Kim, Stéphan Thomassé, and Rémi Watrigant. Twin-width I: tractable FO model checking. J. ACM, 69(1):3:1-3:46, 2022. URL:
  7. Marco Bressan and Marc Roth. Exact and approximate pattern counting in degenerate graphs: New algorithms, hardness results, and complexity dichotomies. In Proceedings of the 62nd IEEE Annual Symposium on Foundations of Computer Science (FOCS), pages 276-285. IEEE, 2021. URL:
  8. Russ Bubley and Martin E. Dyer. Path coupling: A technique for proving rapid mixing in markov chains. In Proceedings of the 38th Annual Symposium on Foundations of Computer Science (FOCS), pages 223-231. IEEE Computer Society, 1997. URL:
  9. Hubie Chen and Stefan Mengel. Counting Answers to Existential Positive Queries: A Complexity Classification. In Proceedings of the 35th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems (PODS), pages 315-326. ACM, 2016. URL:
  10. Yijia Chen, Marc Thurley, and Mark Weyer. Understanding the Complexity of Induced Subgraph Isomorphisms. In Proceedings of the 35th International Colloquium on Automata, Languages and Programming (ICALP), pages 587-596. Springer, 2008. URL:
  11. Radu Curticapean. Counting matchings of size k is W[1]-hard. In Proceedings of the 40th International Colloquium on Automata, Languages, and Programming (ICALP), pages 352-363. Springer, 2013. URL:
  12. Radu Curticapean, Holger Dell, Fedor V. Fomin, Leslie Ann Goldberg, and John Lapinskas. A fixed-parameter perspective on #BIS. Algorithmica, 81(10):3844-3864, 2019. URL:
  13. Radu Curticapean, Holger Dell, and Dániel Marx. Homomorphisms are a good basis for counting small subgraphs. In Proceedings of the 49th Annual ACM SIGACT Symposium on Theory of Computing (STOC), pages 210-223. ACM, 2017. URL:
  14. Radu Curticapean, Holger Dell, and Marc Roth. Counting Edge-Injective Homomorphisms and Matchings on Restricted Graph Classes. In Proceedings of the 34th Symposium on Theoretical Aspects of Computer Science (STACS), pages 25:1-25:15. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2017. URL:
  15. Radu Curticapean and Dániel Marx. Complexity of Counting Subgraphs: Only the Boundedness of the Vertex-Cover Number Counts. In Proceedings of the 55th IEEE Annual Symposium on Foundations of Computer Science (FOCS), pages 130-139. IEEE, 2014. URL:
  16. Marek Cygan, Fedor V. Fomin, Lukasz Kowalik, Daniel Lokshtanov, Dániel Marx, Marcin Pilipczuk, Michal Pilipczuk, and Saket Saurabh. Parameterized Algorithms. Springer, 2015. URL:
  17. Víctor Dalmau and Peter Jonsson. The complexity of counting homomorphisms seen from the other side. Theoret. Comput. Sci., 329(1-3):315-323, 2004. URL:
  18. Julian Dörfler, Marc Roth, Johannes Schmitt, and Philip Wellnitz. Counting Induced Subgraphs: An Algebraic Approach to #W[1]-Hardness. Algorithmica, 84(2):379-404, 2022. URL:
  19. Zdenek Dvorák, Daniel Král, and Robin Thomas. Testing first-order properties for subclasses of sparse graphs. J. ACM, 60(5):36:1-36:24, 2013. URL:
  20. Jörg Flum and Martin Grohe. The Parameterized Complexity of Counting Problems. SIAM J. Comput., 33(4):892-922, 2004. URL:
  21. Jörg Flum and Martin Grohe. Parameterized Complexity Theory. Texts in Theoretical Computer Science. An EATCS Series. Springer, 2006. URL:
  22. Jacob Focke and Marc Roth. Counting small induced subgraphs with hereditary properties. In Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing (STOC), pages 1543-1551. ACM, 2022. URL:
  23. Jakub Gajarský, Petr Hlinený, Daniel Lokshtanov, Jan Obdrzálek, Sebastian Ordyniak, M. S. Ramanujan, and Saket Saurabh. FO model checking on posets of bounded width. In Proceedings of the 56th IEEE Annual Symposium on Foundations of Computer Science (FOCS), pages 963-974. IEEE Computer Society, 2015. URL:
  24. Jakub Gajarský, Petr Hlinený, Jan Obdrzálek, Daniel Lokshtanov, and M. S. Ramanujan. A new perspective on FO model checking of dense graph classes. ACM Trans. Comput. Log., 21(4):28:1-28:23, 2020. URL:
  25. Robert Ganian, Petr Hlinený, Daniel Král, Jan Obdrzálek, Jarett Schwartz, and Jakub Teska. FO model checking of interval graphs. Log. Methods Comput. Sci., 11(4), 2015. URL:
  26. Colin Geniet and Stéphan Thomassé. First order logic and twin-width in tournaments and dense oriented graphs. CoRR, abs/2207.07683, 2022., URL:
  27. Martin Grohe, Stephan Kreutzer, and Sebastian Siebertz. Deciding first-order properties of nowhere dense graphs. J. ACM, 64(3):17:1-17:32, 2017. URL:
  28. Russell Impagliazzo and Ramamohan Paturi. On the Complexity of k-SAT. J. Comput. System Sci., 62(2):367-375, 2001. URL:
  29. Mark Jerrum and Kitty Meeks. The parameterised complexity of counting connected subgraphs and graph motifs. J. Comput. System Sci., 81(4):702-716, 2015. URL:
  30. Mark Jerrum, Alistair Sinclair, and Eric Vigoda. A polynomial-time approximation algorithm for the permanent of a matrix with nonnegative entries. J. ACM, 51(4):671-697, 2004. URL:
  31. Oleksii Kuchaiev, Tijana Milenković, Vesna Memišević, Wayne Hayes, and Nataša Pržulj. Topological network alignment uncovers biological function and phylogeny. Journal of the Royal Society Interface, 7(50):1341-1354, 2010. URL:
  32. László Lovász. Large Networks and Graph Limits, volume 60 of Colloquium Publications. American Mathematical Society, 2012. URL:
  33. Dániel Marx. Can You Beat Treewidth? Theory Comput., 6(1):85-112, 2010. URL:
  34. Dániel Marx. Tractable Hypergraph Properties for Constraint Satisfaction and Conjunctive Queries. J. ACM, 60(6):42:1-42:51, 2013. URL:
  35. Kitty Meeks. The challenges of unbounded treewidth in parameterised subgraph counting problems. Discrete Appl. Math., 198:170-194, 2016. URL:
  36. R. Milo, S. Shen-Orr, S. Itzkovitz, N. Kashtan, D. Chklovskii, and U. Alon. Network Motifs: Simple Building Blocks of Complex Networks. Science, 298(5594):824-827, 2002. URL:
  37. Ron Milo, Shalev Itzkovitz, Nadav Kashtan, Reuven Levitt, Shai Shen-Orr, Inbal Ayzenshtat, Michal Sheffer, and Uri Alon. Superfamilies of evolved and designed networks. Science, 303(5663):1538-1542, 2004. URL:
  38. Jaroslav Nešetřil and Patrice Ossona de Mendez. On nowhere dense graphs. Eur. J. Comb., 32(4):600-617, 2011. URL:
  39. Jaroslav Nešetřil and Patrice Ossona de Mendez. Sparsity - Graphs, Structures, and Algorithms, volume 28 of Algorithms and combinatorics. Springer, 2012. URL:
  40. Jaroslav Nešetřil and Svatopluk Poljak. On the complexity of the subgraph problem. Comment. Math. Univ. Carolin., 26(2):415-419, 1985. URL:
  41. Norbert Peyerimhoff, Marc Roth, Johannes Schmitt, Jakob Stix, Alina Vdovina, and Philip Wellnitz. Parameterized Counting and Cayley Graph Expanders. SIAM J. Discrete Math., to appear. Google Scholar
  42. Marc Roth, Johannes Schmitt, and Philip Wellnitz. Counting Small Induced Subgraphs Satisfying Monotone Properties. SIAM J. Comput., 0(0):FOCS20-139-FOCS20-174, 2022. URL:
  43. Marc Roth and Philip Wellnitz. Counting and finding homomorphisms is universal for parameterized complexity theory. In Proceedings of the 2020 ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 2161-2180. SIAM, 2020. URL:
  44. Benjamin Schiller, Sven Jager, Kay Hamacher, and Thorsten Strufe. StreaM - A Stream-Based Algorithm for Counting Motifs in Dynamic Graphs. In Proceedings of the 2nd International Conference on Algorithms for Computational Biology (AlCoB), pages 53-67. Springer International Publishing, 2015. URL:
  45. Carsten Thomassen. On the presence of disjoint subgraphs of a specified type. J. Graph Theory, 12(1):101-111, 1988. URL:
  46. Ngoc Hieu Tran, Kwok Pui Choi, and Louxin Zhang. Counting motifs in the human interactome. Nature communications, 4(1):1-8, 2013. URL:
  47. Charalampos E. Tsourakakis, Jakub Pachocki, and Michael Mitzenmacher. Scalable motif-aware graph clustering. In Proceedings of the 26th International Conference on World Wide Web (WWW), pages 1451-1460, 2017. URL:
  48. Leslie G. Valiant. The Complexity of Enumeration and Reliability Problems. SIAM J. Comput., 8(3):410-421, 1979. URL:
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