Use a set instead of an array for storing the visited nodes. Sets have O(1) lookup time, resulting in a total time complexity of O(n) for your algorithm, which is otherwise correct.
As for the statement that "going from node a to b to a isn't a cycle",
This is true if you consider simple graphs only and have to use the same edge twice, in multigraphs you may have more than one edge connecting a and b in which case a-b-a over distinct edges counts as a cycle.