|
1234567891011121314151617181920212223242526272829303132333435 |
- /*!
- * \file v12.cpp
- * \brief v1 and v2 part of the exercise.
- *
- * \author
- * Christos Choutouridis AEM:8997
- * <cchoutou@ece.auth.gr>
- */
-
- #include <iostream>
- #include <random>
- #include <v12.h>
-
- namespace v12 {
-
- /*!
- * A naive triangle counting algorithm
- * \param A The adjacency matrix
- * \return The number of triangles
- */
- int triang_count (matrix& A) {
- int count =0;
-
- // We use a symmetric matrix so we iterate using the constrain i<j<k
- A.for_each_in(0, A.size(), [&](auto i) {
- A.for_each_in(i+1, A.size(), [&](auto j) {
- A.for_each_in(j+1, A.size(), [&](auto k){
- count += (A(i,j) && A(i,k) && A(j,k)) ? 1:0;
- });
- });
- });
- return count;
- }
-
- }
|