libFirm
Visited Counters

A visited counter is an alternative to a visited flag for elements of a graph data structure.

A visited counter is an integer number added to the elements of a graph. There is also a global reference number for the whole data structure. It is now possible to mark nodes by setting their visited counter to the global reference counter. Testing is done by comparing with the global reference counter. The advantage to simple boolean flag variables is that you can clear all element marks by increasing the global reference counter and don't need to visit the whole structure. This makes it more efficient when you only visit/mark a small amount of nodes in the graph.