我需要在图中计算一些桥,但是当我对超过100000个顶点进行测试时,我会随机获得一个堆栈溢出,有时我得到一个正确的结果,有时我会得到stackoverflow。出了什么问题? (第9道,至= j.next)
public int findBridgeshelp(int v, int p, boolean[] used, int[] tin, int[] fup, int timer){
used[v] = true;
tin[v] = fup[v] = timer++;
Iterator<Integer> j = lists[v].iterator();
int count=0;
for (int i=0; i<lists[v].size(); ++i) {
int to=0;
if(j.hasNext())
to= j.next();
if (to == p) continue;
if (used[to])
fup[v] = Math.min(fup[v], tin[to]);
else {
count=count+ findBridgeshelp(to, v, used, tin, fup, timer);
fup[v] = Math.min(fup[v], fup[to]);
if (fup[to] > tin[v])
count++;
}
}
return count;
}