Check for a cycle in a graph

I have a directed acyclic graph and I want to check if there is a cycle anywhere in the graph along any path.

The easiest way to do this is if the nodes in the graph had a visited field. But what if this is not possible? What are the other ways to do this?

Check for a cycle in a graph

A simple solution is to have a visited field.. in each node and then you traverse recursively through all paths and set the visited node to true.. and in the process if you find something that is already set to true it menas you have a cycle..

But otherwise (if you do not have an option to modify the node or if it does not have a visited field), I think this is an NP complete problem