| 238 | } |
| 239 | |
| 240 | Node* LCA(Node* x, Node* y) { |
| 241 | while (x != y) { |
| 242 | if (!x || !y) { |
| 243 | return nullptr; |
| 244 | } |
| 245 | if (x->topoIndex < y->topoIndex) { |
| 246 | x = x->domainatePred; |
| 247 | } else { |
| 248 | y = y->domainatePred; |
| 249 | } |
| 250 | } |
| 251 | return x; |
| 252 | } |
| 253 | bool allPathLegal(Node* s, Node* t, MNNForwardType type) { |
| 254 | bool legal = true; |
| 255 | std::queue<Node*> q; |