The algorithm is the hard one and also one of Hackerrank weekcode \$28\$ contest in January 2017, I spent a few hours in the contest to read the problem statement and also read all the discussion. I did some study on disjoint set, but I did not come out clear ideas how to divide groups, implement a graph. I learned through the discussion that the friendship should be added to maximize the value, and studied the test case in the following (5 nodes in the graph):
Add name variable in the class GraphNode to help identify node; add the test case to help understand the algorithm, and be able to add comment to explain the function Connect; use meaningful variable names after code review. I already spent hours on the algorithm and really look forward to work hard on graph algorithm and be able to perform one graph algorithm in week of code contest in short future.