# Why does squaring a matrix with direct food sources show indirect food sources?

I have a matrix that shows a food web and what certain animals eat. the columns represent the animal that is being eaten and the rows represent which animal is eating it. e.g. direct food matrix. this matrix shows the direct food sources which is when animal directly eats another. indirect food sources are when an animal eats another through another animal. e.g. an eagle eats a fox which eats insects so the eagle indirectly eats insects. indirect food source matrix. the indirect food source matrix is just the direct one squared. how does this work? how does squaring the direct food sources give the indirect ones?

This is an example of an adjacency matrix. Consider if "fox eats organism" and "organism eats insects" then $$A_{\text{fox,organism}}=1;A_{\text{organism,insect}}=1$$ and $$A^2 = \sum_j A_{ij} A_{jk}$$ hence $$A^2_{\text{fox, insect}} = \sum_{\text{all organisms}}A_{\text{fox,organism}} A_{\text{organism, insect}}$$ and this will be non zero as long as there is at least one organism that "fox eats organism" and "organism eats insects".