What is a "triangle" in a graph, and what is the formula for calculating the number of triangles in a graph using the eigenvalues of the adjacency matrix.
Any help will be much appreciated,
What is a "triangle" in a graph, and what is the formula for calculating the number of triangles in a graph using the eigenvalues of the adjacency matrix.
Any help will be much appreciated,
For a graph $G=(V,E)$, a triangle is a path of length 3, meaning a cycle with 3 nodes (if drawing the graph, it forms a triangle, graphically). Let $A$ be the adjacency matrix, where $[A]_{ij} = a_{ij} = \mathbb{I}[e_{ij}\in E] $. Assume no self-edges.
First, note that $A^k=\prod_{i=1}^k A$ counts the number of length $n$ paths between each pair of nodes. I.e., $ a_{ij}^k = \#_k(i\rightarrow j)$ is the number of ways to get from vertex $i$ to $j$ in $k$ steps. Why? Well, by induction, $A$ satisfies this, since the edges are the only length $1$ paths. Supposing the property is true for some $k$, notice that multiplying $A^k$ by $A$ has components: $$ [A^k]_{ij} = a^k_{ij} = \sum_{v\in V} \#_k(i\rightarrow v) \#_1(v\rightarrow j) $$ Notice that once you reach $v$ from $i$, all the possible paths from $v$ to $j$ form the complete paths from $i$ and $j$ through $v$. So we multiply the counts. All such paths are length $k+1$ because $i$ to $v$ takes one step and summing over all $v$ covers all length $k+1$ paths (and only length $k+1$ paths). This gives us all ways from $i$ to $j$ through each $v$, meaning $ a_{ij}^k = \#_{k+1}(v\rightarrow j) $. Another way to see it is by considering normalizing it and treating it as the Markov chain transition matrix. See here as well.
Given this, consider that $a^3_{ii}$ counts the number of length 3 paths from $i$ to $i$: each such one of these is a triangle! So we can get a count of all triangles via: $$ C_a(G) = \sum_i a^k_{ii} = \text{tr}(A^3) $$ But this overcounts the triangles, because each triangle will appear $6$ times ($v_i\rightarrow v_j \rightarrow v_\ell$ can be rearranged/permuted in $3\cdot 2\cdot 1=6$ ways). So we should use $$ C(G) = \frac{1}{6}\text{tr}(A^3) $$
Finally, recall that the trace of a matrix is equal to the sum of its eigenvalues. So let $\lambda_\alpha$ be the $\alpha$th eigenvalue of $A$. Next, recall that $A$ being symmetric means it has an eigendecomposition and that the eigenvalues of $A^k$ are the $k$th powers of the eigenvalues of $A$ (here and here). So $\lambda_i^3$ is the $i$th eigenvalue of $A^3$.
Thus we can write the solution in terms of the eigenvalues of the adjacency matrix via $$ C(G) = \frac{1}{6}\sum_i \lambda_i^3 $$ where we used the fact that $\text{tr}(A^3) = \sum_i \lambda^3_i$.
See also this post as noted by the commentor above.