smarten up the ordering loop
Switch back to storing marked edges on the graph

Storing on layers was initially done to distinguish edges that
have the same destination but are in different layers. This was
silly for several reasons, but a subsequent change specified
the source of an edge in addition to the destination, so this is
no longer needed. It also removes the problem of determining
which layer to store the marked edges on, which changes depending
on whether we're in the middle of a forward or backward pass
through the graph.