Forward propagation in complicated neural networks
You can do topological sorting. For example, here is some pythonic pseudocode

def order(current_neuron, level):
    current_neuron.level = max(level, current_neuron.level)
    for child in sorted(current_neuron.children, key=children level, reverse=True):
        order(child, level + 1)

for input_neuron in input_neurons:
    order(input_neuron, level=0)


(Take this pseudo code with a grain of salt. This is just what came directly to my mind; it is not tested.)

Then you can calculate the activations in order of node.level.