Listing Triangles

  • Andreas Björklund
  • Rasmus Pagh
  • Virginia Vassilevska Williams
  • Uri Zwick
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8572)


We present new algorithms for listing triangles in dense and sparse graphs. The running time of our algorithm for dense graphs is \(\tilde{\mathcal O}(n^{\omega} + n^{3(\omega-1)/(5-\omega)} t^{2(3-\omega)/(5-\omega)})\), and the running time of the algorithm for sparse graphs is \(\tilde{\mathcal O}(m^{{2\omega}/{(\omega+1)}} + m^{{3(\omega-1)}/{(\omega+1)}} t^{{(3-\omega)}/{(\omega+1)}})\), where n is the number of vertices, m is the number of edges, t is the number of triangles to be listed, and ω < 2.373 is the exponent of fast matrix multiplication. With the current bound on ω, the running times of our algorithms are \(\tilde{\mathcal O}( n^{2.373} + n^{1.568}\, t^{0.478})\) and \(\tilde{\mathcal O}(m^{1.408} + m^{1.222}\, t^{0.186})\), respectively. We first obtain randomized algorithms with the desired running times and then derandomize them using sparse recovery techniques.

If ω = 2, the running times of the algorithms become \(\tilde{\mathcal O}(n^2+nt^{2/3})\) and \(\tilde{\mathcal O}(m^{4/3}+mt^{1/3})\), respectively. In particular, if ω = 2, our algorithm lists m triangles in \(\tilde{\mathcal O}(m^{4/3})\) time. Pǎtraşcu (STOC 2010) showed that Ω(m 4/3 − o(1)) time is required for listing m triangles, unless there exist subquadratic algorithms for 3SUM. We show that unless one can solve quadratic equation systems over a finite field significantly faster than the brute force algorithm, our triangle listing runtime bounds are tight assuming ω = 2, also for graphs with more triangles.


Sparse Graph Quadratic Equation System Sparse Recovery High Degree Vertex Sparse Signal Recovery 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Afrati, F.N., Fotakis, D., Ullman, J.D.: Enumerating subgraph instances using Map-Reduce. In: Proc. IEEE International Conference on Data Engineering (ICDE), pp. 62–73 (2013)Google Scholar
  2. 2.
    Alon, N., Yuster, R., Zwick, U.: Color-coding. J. ACM 42(4), 844–856 (1995)CrossRefzbMATHMathSciNetGoogle Scholar
  3. 3.
    Aumann, Y., Lewenstein, M., Lewenstein, N., Tsur, D.: Finding witnesses by peeling. ACM Transactions on Algorithms 7(2), 24 (2011)CrossRefMathSciNetGoogle Scholar
  4. 4.
    Berry, J., Fostvedt, L., Nordman, D., Phillips, C., Seshadhri, C., Wilson, A.: Why do simple algorithms for triangle enumeration work in the real world? In: Proc. Innovations in Theoretical Computer Science (2014)Google Scholar
  5. 5.
    Berry, J.W., Hendrickson, B., LaViolette, R.A., Phillips, C.A.: Tolerating the community detection resolution limit with edge weighting. Phys. Rev. E 83, 056119 (2011)Google Scholar
  6. 6.
    Chu, S., Cheng, J.: Triangle listing in massive networks. ACM Trans. Knowl. Discov. Data 6(4), 17:1–17:32 (2012)Google Scholar
  7. 7.
    Courtois, N., Klimov, A., Patarin, J., Shamir, A.: Efficient algorithms for solving overdefined systems of multivariate polynomial equations. In: Preneel, B. (ed.) EUROCRYPT 2000. LNCS, vol. 1807, pp. 392–407. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  8. 8.
    Welles, B.F., Van Devender, A., Contractor, N.: Is a friend a friend? Investigating the structure of friendship networks in virtual worlds. In: CHI 2010 Extended Abstracts on Human Factors in Computing Systems, pp. 4027–4032. ACM (2010)Google Scholar
  9. 9.
    Gasieniec, L., Kowaluk, M., Lingas, A.: Faster multi-witnesses for boolean matrix multiplication. Inf. Process. Lett. 109(4), 242–247 (2009)CrossRefzbMATHMathSciNetGoogle Scholar
  10. 10.
    Hu, X., Tao, Y., Chung, C.-W.: Massive graph triangulation. In: Proc. of SIGMOD, pp. 325–336. ACM (2013)Google Scholar
  11. 11.
    Huang, X., Pan, V.Y.: Fast rectangular matrix multiplication and applications. J. of Complexity 14(2), 257–299 (1998)CrossRefzbMATHMathSciNetGoogle Scholar
  12. 12.
    Indyk, P.: Explicit constructions for compressed sensing of sparse signals. In: Proc. of 19th SODA, pp. 30–33 (2008)Google Scholar
  13. 13.
    Itai, A., Rodeh, M.: Finding a minimum circuit in a graph. SIAM Journal on Computing 7(4), 413–423 (1978)CrossRefzbMATHMathSciNetGoogle Scholar
  14. 14.
    Jafargholi, Z., Viola, E.: 3SUM, 3XOR, triangles. CoRR, abs/1305.3827 (2013)Google Scholar
  15. 15.
    Kipnis, A., Shamir, A.: Cryptanalysis of the HFE public key cryptosystem by relinearization. In: Wiener, M. (ed.) CRYPTO 1999. LNCS, vol. 1666, pp. 19–30. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  16. 16.
    Kolountzakis, M.N., Miller, G.L., Peng, R., Tsourakakis, C.E.: Efficient triangle counting in large graphs via degree-based vertex partitioning. Internet Mathematics 8(1-2), 161–185 (2012)CrossRefzbMATHMathSciNetGoogle Scholar
  17. 17.
    Landau, S.: Polynomials in the nation’s service: using algebra to design the advanced encryption standard. American Mathematical Monthly 111, 89–117 (2004)CrossRefzbMATHMathSciNetGoogle Scholar
  18. 18.
    Le Gall, F.: Powers of tensors and fast matrix multiplication. CoRR, abs:1401.7714 (2014)Google Scholar
  19. 19.
    Gall, F.L.: Faster algorithms for rectangular matrix multiplication. In: Proc. Foundations of Computer Science, pp. 514–523 (2012)Google Scholar
  20. 20.
    Pagh, R., Silvestri, F.: The input/output complexity of triangle enumeration. arXiv preprint arXiv:1312.0723 (2013)Google Scholar
  21. 21.
    Patarin, J.: Cryptoanalysis of the matsumoto and imai public key scheme of eurocrypt’88. In: Coppersmith, D. (ed.) CRYPTO 1995. LNCS, vol. 963, pp. 248–261. Springer, Heidelberg (1995)Google Scholar
  22. 22.
    Porat, E., Strauss, M.J.: Sublinear time, measurement-optimal, sparse recovery for all. In: Proc. of 23rd SODA, pp. 1215–1227. SIAM (2012)Google Scholar
  23. 23.
    Pǎtraşcu, M.: Towards polynomial lower bounds for dynamic problems. In: Proc. of 42nd STOC, pp. 603–610 (2010)Google Scholar
  24. 24.
    Schank, T., Wagner, D.: Finding, counting and listing all triangles in large graphs, an experimental study. In: Nikoletseas, S.E. (ed.) WEA 2005. LNCS, vol. 3503, pp. 606–609. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  25. 25.
    Wang, N., Zhang, J., Tan, K.-L., Tung, A.K.: On triangulation-based dense neighborhood graph discovery. Proc. VLDB Endowment 4(2), 58–68 (2010)Google Scholar
  26. 26.
    Williams, V.V.: Multiplying matrices faster than coppersmith-winograd. In: Proc. of 44nd STOC, pp. 887–898 (2012)Google Scholar
  27. 27.
    Williams, V.V., Williams, R.: Subcubic equivalences between path, matrix and triangle problems. In: Proc. IEEE Foundations of Computer Science (FOCS), pp. 645–654 (2010)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2014

Authors and Affiliations

  • Andreas Björklund
    • 1
  • Rasmus Pagh
    • 2
  • Virginia Vassilevska Williams
    • 3
  • Uri Zwick
    • 4
  1. 1.Department of Computer ScienceLund UniversitySweden
  2. 2.IT University of CopenhagenDenmark
  3. 3.Computer Science DepartmentStanford UniversityUSA
  4. 4.Blavatnik School of Computer ScienceTel Aviv UniversityIsrael

Personalised recommendations