【发布时间】:2017-05-12 21:54:30
【问题描述】:
我正在尝试在图形上执行一些基本功能(使用布尔矩阵)。除了 DFS 之外,它们都可以工作。它给了我一些随机数。几个小时以来我一直在尝试解决这个问题,但仍然没有......(代码编译,但它显示错误)。顺便说一句,DFS 的结果必须是一个矩阵,有栈数,还有每个图顶点的“展开”。
我的错误在哪里?
我的程序:
public int[][] DFS(int s) {
Stack<Integer> stack = new Stack<Integer>();
stack.push(s);
int recorder = 1;
int[][] mark = new int[nbs][2];
mark[s][0] = recorder++;
boolean[] decouvert = new boolean[nbs];
while (!stack.isEmpty()) {
s = stack.pop();
mark[s][1] = recorder++;
if (!decouvert[s]) {
decouvert[s] = true;
for (int i = 0; i < nbs; i++) {
if (m[s][i]) {
stack.push(i);
mark[s][0] = recorder++;
}
}
}
}
return mark;
}
【问题讨论】:
-
我的变量“decouvert”的意思是“发现”
标签: java graph microsoft-distributed-file-system