Say I have the edges

```
A -> C
A -> D
A -> E
B -> D
B -> E

```

To maximise data locality I'd arrange for the DAG to be stored in this order in memory (as an array) to minimise the distance between the node and it's dependencies.

```
C, A, D, E, B

```

so that A has a distance 1 to C, 1 to D, 2 to E.

And that B has a distance of 1 to E, and 2 to D.

Is there name for an algorithm that does this? If not, how would one implement this?