class Apriori {

	public static <T> Map<Set<T>, Double> extractItemsets(Collection<Set<T>> data, double minSupport) {
		Map<Set<T>, Double> result = new HashMap<>();
		Set<Set<T>> L_k_minus_1 = new HashSet<>();
		Collection<Set<T>> C_k_minus_1 = getSingleCandidates(data);
		for (Set<T> c : C_k_minus_1) {
			double support = support(c, data);
			if (support >= minSupport) {
				L_k_minus_1.add(c);
				result.put(c, support);
			}
		}
		for (;;) {
			Set<Set<T>> C_k = aprioriGen(L_k_minus_1);
			Set<Set<T>> L_k = new HashSet<>();
			for (Set<T> c : C_k) {
				double support = support(c, data);
				if (support >= minSupport) {
					L_k.add(c);
					result.put(c, support);
				}
			}
			if (L_k.isEmpty()) {
				break;
			}
			L_k_minus_1 = L_k;
		}
		return result;
	}

	private  Apriori();

}