Merging the final groups
For example, consider these two graphs, which are almost identical except that in the first, w6 targets shard D and in the second in targets B. In the second graph, w6 has been placed in its own group rather than merging it into the [w1] group, because according to the above discussion we should place w6 in a group whose depth is at least 1.
Shard │
│ ┌───────────┐
A │ │ w2 w3 │
│ └/─────────\┘
│ / \
│ ┌───/┐ \
B │ │ w1 │ \
│ └────┘ \
│ \
│ ┌────┐ ┌\───┐
C │ │ w5 │ │ w4 │
│ └───\┘ └────┘
│ \
│ ┌\───┐
D │ │ w6 │
│ └────┘
Shard │
│ ┌───────────┐
A │ │ w2 w3 │
│ └/─────────\┘
│ / \
│ ┌───/┐ ┌────┐ \
B │ │ w1 │ │ w6 │ \
│ └────┘ └/───┘ \
│ / \
│ ┌────┐ / ┌\───┐
C │ │ w5 ───' │ w4 │
│ └────┘ └────┘
In both these graphs, the [w5] and [w4] groups can be merged at the cost of increasing D from three to four. In the second graph it is possible to instead merge the [w1] and [w6] groups, which also increases D to four. That is, we could end up with either of these graphs after performing group merging on the second graph:
Shard │
│ ┌───────────┐
A │ │ w2 w3 │
│ └/─────────\┘
│ / \
│ ┌───/┐ \ ┌────┐
B │ │ w1 │ \ │ w6 │
│ └────┘ \ └/───┘
│ \ /
│ ┌\─────────/┐
C │ │ w4 w5 │
│ └───────────┘
Shard │
│ ┌───────────┐
A │ │ w2 w3 │
│ └/─────────\┘
│ / \
│ ┌───────────/┐ \
B │ │ w6 w1 │ \
│ └/───────────┘ \
│ / \
│ ┌───/┐ ┌\───┐
C │ │ w5 │ │ w4 │
│ └────┘ └────┘
There’s no reason to prefer either of these as they have the same N and D values. What’s important to note is that the decision to merge [w1] and [w6], or to merge [w4] and [w5] are mutually exclusive; once one of these merges has been done, the other is illegal without violating causality.