// Copy constructor public Component(Component previousComponent) { ID_ = previousComponent.ID_; x_ = previousComponent.x_; y_ = previousComponent.y_; links_ = previousComponent.links_; }
// Swap the coordinates of two components public Component permutation(Component other) { Component tmp = new Component(other); tmp.x_ = this.x_; tmp.y_ = this.y_; this.x_ = other.x_; this.y_ = other.y_; return tmp; }
// Compute the Manhattan length between two components static int manhattan(Component a, Component b) { return (Math.Abs(a.x_ - b.x_) + Math.Abs(a.y_ - b.y_)); }