在Flinoyd-Warshall/Dijkstra对洪水做出答复之前,请让我解释一下这一情况,即确保这两种算法都能够用于本案,而且这并不是一个简便的范例方案(你在java必须保持可以承受的记忆力)。
第3号是第0号至第1号的网页,因为第5号是第5号,第3号是第3号是第4号。 每一“node”在_neighbours[nodeID]和_neighbours[nodeID] 之间都有代表,因此,我们再谈一下诺德。 3. 又注意到在_/out_中,两者都分类(自然分类为5)将一劳永逸地选择其联系,但只有6个选择——这样3个联系——永远不会包含{6、5、7})和c 两者可以包含重复。 (在/外有色体大小的阵列,其中总大小为小或小米,而用户在开始时也规定了N)
无重量。 必须做的是找到平均差异。
public double getAvgDistance() {
int sum = 0;
for (int i=1; i<n; i++) {
for (int j=0; j < i; j++) {
sum += dist(i, j); // there are duplicates, make sure i skip
}
}
return (double)sum / (double)( ((n*(n-1)) / 2) );
}
我迄今的情况是最好的。 说明一只希望找到“j &”之间的距离,即不是同时所有的距离(没有足够记忆,将在m=20 d=1 000上测试)。
private int dist(int i, int j) {
int dist = 0;
for (int link : in_neighbours[j]) {
System.out.print("
Is "+j+" linked to by "+i);
if (out_neighbours[i].contains(link)) {
System.out.print(" - yes!");
dist = 1;
}
}
return dist;
}
因此,不问“fresher”(此时此刻完成图表)是否将“fresher”与任何较老的ud直接联系起来,如果是的话,距离是一环。
如果 no子被 trav倒,这是否只是我,或者说最短的道路永远是第一条道路?
How do i check if its not 1, the "else" after the base case? My math is fairly weak please be gentle :) Any hints how to make use of the fact that the links are sorted?
它不是家庭工作,也不是试图从中挑出来的东西,它并不涉及守则本身,而是必须是一种有用的tool<>em>,“学习”本身就是这样。
这里的图表如何看待数据交换,在m=7 n=13的链接中发现链接(脚注0的周期只是图表的初始化):
0 | 0 0 0 0 0 0 0 | 0 0 0 0 0 0 0 1 1 1 1 1 1 1 2 2 2 2 2 3 4 5 6 6 7 8 9
1 | 0 0 0 0 0 0 0 | 2 2 3 4 5 5 8 12
2 | 0 0 0 0 0 1 1 | 3 3 3 3 3 4 4 4 6 7 8 10
3 | 0 1 2 2 2 2 2 | 4 4 5 5 6 6 7 11
4 | 0 1 2 2 2 3 3 | 5 5 6 8 9 10
5 | 0 1 1 3 3 4 4 | 6 7 8 9 9 11 12
6 | 0 0 2 3 3 4 5 | 7 7 7 8 9 9 12
7 | 0 2 3 5 6 6 6 | 8 9 10 11 11 12
8 | 0 1 2 4 5 6 7 | 10 10 10 11 12
9 | 0 4 5 5 6 6 7 | 10 11 11
10 | 2 4 7 8 8 8 9 | 12 12
11 | 3 5 7 7 8 9 9 |
12 | 1 5 6 7 8 10 10 |
Sorry for the agonising long read. EDIT: Wrong code in the methods, this is what i think is correct now.
3. 修订 dis2,只是尝试和找到一条道路:
private int dist(int i, int j) {
int dist = 0, c = 0, count = 0;
boolean linkExists = false;
for (int link : in_neighbours[j]) {
//System.out.print("
Is "+j+" linked to by "+i);
if (out_neighbours[i].contains(link)) {
//System.out.print(" - yes!");
dist = 1; // there is a direct link
} else {
while ( c < j ) {
// if there s a path from 0 up to j, check if i links to a node which eventually links to j
if (out_neighbours[i].contains(c) &&
(out_neighbours[c].contains(link) || in_neighbours[c].contains(link) )) {
count++; // yes. and this is one node we had to step through to get closer
linkExists = true;
} else {
linkExists = false; // unreachable, the path was interrupted somewhere on the way
break;
}
c++;
}
if (linkExists) {
dist = count-1; // as 2 nodes are linked with 1 edge
} else {
dist = 0; // no path was found
}
}
}
return dist;
}