2
public int minCostConnectPoints(int[][] points) {3
int len = points.length;4
// array that keep track of the shortest distance from mst to each node5
int[] disArr = new int[len];6
for (int i = 1; i < len; ++i) {7
disArr[i] = Integer.MAX_VALUE;9
// visited[node] == true if node in mst10
boolean[] visited = new boolean[len];14
// current node, used to update the disArr19
while (numEdge++ < len - 1) {20
int minEdge = Integer.MAX_VALUE;22
for (int i = 0; i < len; ++i) {23
// if the node i is not in mst25
// find the distance between cur and i27
Math.abs(points[cur][0] - points[i][0]) + Math.abs(points[cur][1] - points[i][1]);28
// update distance array29
disArr[i] = Math.min(dis, disArr[i]);30
// find the shortest edge31
if (disArr[i] < minEdge) {