static void linkPartitions(List<Node> positiveNodes,
                               List<Node> negativeNodes,
                               int[] positiveIndices,
                               int[] negativeIndices,
                               Graph result) {
        int k = 0;

        for (int i : positiveIndices) {
            if (k < i) {
                k = i;
            }
        }

        ++k;

        // Here, k is the amount of groups.

        List<Node>[] positiveGroups = new List[k];
        List<Node>[] negativeGroups = new List[k];

        int i = 0;

        for (int index : positiveIndices) {
            if (positiveGroups[index] == null) {
                positiveGroups[index] =
                        new ArrayList<Node>(positiveNodes.size());
            }

            positiveGroups[index].add(positiveNodes.get(i++));
        }

        i = 0;

        for (int index : negativeIndices) {
            if (negativeGroups[index] == null) {
                negativeGroups[index] =
                        new ArrayList<Node>(negativeNodes.size());
            }

            negativeGroups[index].add(negativeNodes.get(i++));
        }

        Arrays.sort(positiveGroups, nodeListEquityComparator);
        Arrays.sort(negativeGroups, nodeListEquityComparator);

        for (i = 0; i < k; ++i) {
            checkGroup(positiveGroups[i], negativeGroups[i]);
            linkGroup(positiveGroups[i], negativeGroups[i], result);
        }
    }