我需要实现一个使用here中的数据找到的here(第5页)的算法(如果您希望深入挖掘,请选择facebook data,大小仅为KB)算法是:
1: Ti ← 0 //Ti is pi’s count of triangles
2: for v ∈ Vi do
3: for u ∈ Nv do
4: if u ∈ Vi then
5: S ← Nv ∩ Nu
6: Ti ← Ti + |S|
7: else if u ∈ Vj then
8: Send <data,Nv> to pj if not sent already
9:
10: Check for incoming messages <t,X>:
11: if t = data then
12: Ti ← Ti+ SURROGATECOUNT(X, i)
13: else
14: Increment completion counter
15:
16: Broadcast <notifier,X>
17: while completion counter < P-1 do
18: Check for incoming messages <t,X>:
19: if t = data then
20: Ti ← Ti+ SURROGATECOUNT(X, i)
21: else
22: Increment completion counter
23:
24: MPIBARRIER
25: Find Sum T ← Pi Ti using MPIREDUCE
26: return T
据我所知,我需要一个二维数组我需要查询
if
语句中的每个元素,并在Ti
变量处执行+1。第一个问题,
S ← Nv ∩ Nu
如何分配这个变量?维基百科说:
S
第二个问题,如果你看一下数据,我需要所有的数据吗?我想我只需要
A ∩ B means the set that contains all those elements that A and B have in common.
文件。 最佳答案
S ← Nv ∩ Nu
Ti ← Ti + |S|
看起来您只需要
Nv
和Nu
中的元素数。所以只要按这个数字把它们加起来就行了。该算法似乎没有将Ti
集合用于任何其他用途。看起来你不需要太多关于这些联系的信息,所以只要。边缘就足够了。
关于algorithm - 分析和理解该算法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35316724/