Given a graph G: how to find a formula to determine the number of squares in which a vertex participates?

365 Views Asked by At

I should find a formula that, given a certain vertex v1 of a graph G, it returns the number of squares in which v1 participates.

I managed to find a solution for triangles, but in the case of squares, I am a having a hard time trying to figure out how to build a formula that distinguishes those walks that form a square starting at v1 and finishing at v1 from those walks that have length 4 and which do not form an actual square.

Any help would be greatly appreciated. Thank you.-