利用hadoop来解决“共同好友”的问题
假设A有好友B C D;B有好友A C D E;C有好友A B D E;D有好友A B C E;E有好友B C D。
A -> B C D
B -> A C D E
C -> A B D E
D -> A B C E
E -> B C D
则
对于A来说,A -> B C D
(A B) -> B C D
(A C) -> B C D
(A D) -> B C D
对于B来说,B -> A C D E
(A B) -> A C D E
(B C) -> A C D E
(B D) -> A C D E
(B E) -> A C D E
对于C来说,C -> A B D E
(A C) -> A B D E
(B C) -> A B D E
(C D) -> A B D E
(C E) -> A B D E
对于D来说,D -> A B C E
(A D) -> A B C E
(B D) -> A B C E
(C D) -> A B C E
(D E) -> A B C E
对于E来说,E -> B C D
(B E) -> B C D
(C E) -> B C D
(D E) -> B C D
汇总得到
(A B) -> (A C D E) (B C D)
(A C) -> (A B D E) (B C D)
(A D) -> (A B C E) (B C D)
(B C) -> (A B D E) (A C D E)
(B D) -> (A B C E) (A C D E)
(B E) -> (A C D E) (B C D)
(C D) -> (A B C E) (A B D E)
(C E) -> (A B D E) (B C D)
(D E) -> (A B C E) (B C D)
则共同好友的关系是
(A B) -> (C D)
(A C) -> (B D)
(A D) -> (B C)
(B C) -> (A D E)
(B D) -> (A C E)
(B E) -> (C D)
(C D) -> (A B E)
(C E) -> (B D)
(D E) -> (B C)