Keeps a directed acyclic graph topologically sorted each time you add an edge or vertex to check for cycles.