getRoot method
Returns the root node of the graph that this node is a part of.
Implementation
Node getRoot() {
Node? current = this;
while (current!._parent != null) {
current = current._parent;
}
return current;
}
Returns the root node of the graph that this node is a part of.
Node getRoot() {
Node? current = this;
while (current!._parent != null) {
current = current._parent;
}
return current;
}