Check if tree is valid (has a root and non-empty parents).
| 43 | |
| 44 | // Check if tree is valid (has a root and non-empty parents). |
| 45 | bool IsValid() const { return root >= 0 && !parents.empty(); } |
| 46 | |
| 47 | // Get the number of nodes in the tree. |
| 48 | size_t NumNodes() const { return parents.size(); } |