📄 bestnode.java
字号:
public class BestNode {
int[][] m;
int n;
int node, cost;
BestNode(int[][] m, int n) {
this.m = m;
this.n = n;
}
int bestNode(int i, boolean[] b) {
BestWay bw = new BestWay(m, n);
boolean flag = true;
int j = 0;
for (j = 0; j < n; j++) {
flag &= b[j];
}
if (flag){
return i;
}
int min = 1000;
for (j = 1; j < n; j++) {
if (b[j] == true)
continue;
b[j] = true;
cost = m[i][j] + bw.bestWay(j, b);
if (min > cost) {
min = cost;
node = j;
}
b[j] = false;
}
return node;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -