Finding a cycle from an ordered list

34 Views Asked by At

Given a random list of all square matrix elements e.g. $\{A_{1,3},A_{2,5},A_{2,1},A_{3,2}, \dots\}$

I want to be able to find the first 3-cycle $\{A_{a,b},A_{b,c},A_{c,a}\}$ in this list.

This is the same as constructing a graph edge by edge and asking for the edges of the first triangle to appear. What is an efficient way to find the triangle?

Thanks in advance. Ben