I have a Directed Acyclic Graph (it's causal, but that's actually not important for this question). Suppose I have the chain $A\to B\to C\to D.$ I want a row output consisting of all possible ancestor-descendant pairs, like this:
| Root | Ancestor | Ancestor Generation | Descendant | Descendant Generation |
|---|---|---|---|---|
| A | A | 0 | B | 1 |
| A | A | 0 | C | 2 |
| A | A | 0 | D | 3 |
| A | B | 1 | C | 2 |
| A | B | 1 | D | 3 |
| A | C | 2 | D | 3 |
The "generation" numbers are essentially how many hops away from the root that node is. Is there a name for this algorithm?