MapReduce公共朋友伪代码

MapReduce公共朋友伪代码,mapreduce,pseudocode,Mapreduce,Pseudocode,我目前正在尝试开发一些MapReduce伪代码,用于计算特定站点的每个用户的共同好友数。然而,友谊不是相互的,这就是我的问题所在。 我的输入包括用户及其各自朋友的列表,格式如下: A->(bce),B->(cfh)等等 到目前为止,我开发的伪代码是 MAP (String Input_key, String Input_Value): \\ Input_key: person \\ Input_Value: list of their friends for each pair in Input

我目前正在尝试开发一些MapReduce伪代码,用于计算特定站点的每个用户的共同好友数。然而,友谊不是相互的,这就是我的问题所在。 我的输入包括用户及其各自朋友的列表,格式如下: A->(bce),B->(cfh)等等

到目前为止,我开发的伪代码是

MAP (String Input_key, String Input_Value):
\\ Input_key: person
\\ Input_Value: list of their friends
for each pair in Input_Value:
Emit (pair, 1)

REDUCE (String Intermediate_key, Iterator (Intermediate_Values):
\\ Intermediate_key: pair of friends
\\ Intermediate_values: list of '1's corresponding to the number of people who are friends with both in the pair
int count = 0;
for each v value in Intermediate_values:
count += ParseInt (v);
Emit (Intermediate_key, count);
然而,我不认为上面的代码适用于友谊不是相互的情况(仅仅因为A是B和C对的朋友并不意味着B和C是A对的朋友)

有谁能解释一下,或者给我指出解决这个问题的正确方向吗

非常感谢您的帮助

提前谢谢