# Tracking / calculating dependencies of nodes

I have a problem regarding dependencies. I'm making a circuit simulator thingy and I stumbled upon the problem of determining which circuit component should be updated first (since updates in my case mean that the output is transformed based on its inputs according to some specified behaviour, the behaviour being irrelevant). How does one efficiently tackle this problem and how does he approach the problem of circular dependencies? (e.g. in counters)

Sources on the topic are much appreciated!

If there are no circular dependencies you can just use a topological order of the associated directed graph (that contains edge $$(u,v)$$ if $$v$$ uses the output of $$u$$ as an input).