I'm using ConnectivityInspector to get the connected trees from a graph using the method connectedSets() which give me a List of Hashsets
ConnectivityInspector s = new ConnectivityInspector<>(graph);
System.out.println(s.connectedSets());
it would give me all the trees of the forest for example [ [13, 14], [15], [16, 17, 18, 19, 20, 21, 22], [23], [36], [38, 39], [40], [41], [52], [56, 120], [58, 122, 186] ]
My question now that I stuck on it is that how to get the sum of every tree to get then the average of this tree. for example: s.connectedSets().get(0) = [13, 14]. How can I add both 13 and 14 and before that make them integer . I try many ways but I couldn't catch the solution .