class Step6GraphTransitivityCleaner {

    public static Set<Set<String>> mergeClusters(Set<Set<String>> equalClusters)
    {
        // create a new undirected graph
        Graph graph = new DefaultGraph("CC Test");
        graph.setAutoCreate(true);
        graph.setStrict(false);

        // add all "edges"; for each pair from each cluster
        for (Set<String> cluster : equalClusters) {
            List<String> clusterList = new ArrayList<>(cluster);

            for (int i = 0; i < clusterList.size(); i++) {
                for (int j = i + 1; j < clusterList.size(); j++) {
                    // edge name
                    String iName = clusterList.get(i);
                    String jName = clusterList.get(j);

                    List<String> names = Arrays.asList(iName, jName);
                    Collections.sort(names);
                    String edgeName = StringUtils.join(names, "_");

                    graph.addEdge(edgeName, iName, jName);
                }
            }
        }

        // compute connected components
        ConnectedComponents cc = new ConnectedComponents();
        cc.init(graph);

        Set<Set<String>> result = new HashSet<>();

        cc.setCountAttribute("cluster");
        cc.compute();

        //        System.out.println(cc.getConnectedComponentsCount());

        // re-create clusters from all connected components
        for (ConnectedComponents.ConnectedComponent component : cc) {
            Set<String> cluster = new HashSet<>();
            for (Node n : component) {
                cluster.add(n.getId());
            }
            result.add(cluster);
        }

        //        System.out.println(result);

        return result;
    }

    public  Step6GraphTransitivityCleaner(ArgumentPairListSorter argumentPairListSorter,
            boolean removeEqualEdgesParam);

}