FIND2 { void execute() throws AlgorithmExecutionException { log.fine("Start of algorithm FIND2."); List<InclusionDependency> inputInds = inclusionDependencyInput.execute(); Set<ExIND> unaries = getUnaryINDs(inputInds); Set<ExIND> karies = getKaryINDs(config.getStartK(), inputInds); Set<ExIND> karies1 = karies; Set<ExIND> validINDs = unaries .stream() .filter(unary -> karies1.stream().noneMatch(kary -> kary.contains(unary))) .collect(Collectors.toCollection(HashSet::new)); unaries.removeAll(validINDs); for (int k = config.getStartK(); k < unaries.size(); k++) { Hypergraph graph = new Hypergraph(k, unaries, karies); Set<ExIND> cliques = graph.getCliquesOfCurrentLevel(); validateINDs(cliques); Set<ExIND> validINDCandidates = new HashSet<>(); Set<ExIND> invalidINDCandidates = new HashSet<>(); cliques.forEach( clique -> (clique.isValid() ? validINDCandidates : invalidINDCandidates).add(clique)); validINDs.addAll(validINDCandidates); Set<ExIND> newKaries = getKaries(k + 1, invalidINDCandidates); validateINDs(newKaries); Set<ExIND> validNewKaries = newKaries.stream().filter(ExIND::isValid).collect(Collectors.toCollection(HashSet::new)); validINDs.addAll(genSubINDs(karies, validNewKaries, validINDs)); if (validNewKaries.size() < k + 1) { validINDs.addAll(validNewKaries); returnResults(validINDs); return; } karies = validNewKaries; } } FIND2(FIND2Configuration config);   }
@Test void testPaperExample() throws Exception { String relationName = "TEST"; List<String> columnNames = asList("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N"); List<ColumnIdentifier> ci = new ArrayList<>(); for (String c : columnNames) { ci.add(new ColumnIdentifier(relationName, c)); } List<ExIND> maximumINDs = new ArrayList<>(); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(0), ci.get(1), ci.get(2), ci.get(3), ci.get(4)), new ColumnPermutation(ci.get(7), ci.get(8), ci.get(9), ci.get(10), ci.get(11)))); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(3), ci.get(5), ci.get(6)), new ColumnPermutation(ci.get(10), ci.get(12), ci.get(13)))); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(4), ci.get(5)), new ColumnPermutation(ci.get(11), ci.get(12)))); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(4), ci.get(6)), new ColumnPermutation(ci.get(11), ci.get(13)))); testDatabase = TestDatabase.builder() .resourceClass(FIND2Test.class) .relationName(relationName) .columnNames(columnNames) .csvPath("testPaperExample.csv") .build(); testDatabase.setUp(); InclusionDependencyResultReceiverStub resultReceiver = new InclusionDependencyResultReceiverStub(); ValidationParameters validationParameters = new ValidationParameters(); validationParameters.setQueryType(QueryType.NOT_IN); validationParameters.setConnectionGenerator(testDatabase.asConnectionGenerator()); InclusionDependencyParameters inclusionDependencyParameters = new InclusionDependencyParameters(); inclusionDependencyParameters.setAlgorithmType(AlgorithmType.FILE); inclusionDependencyParameters .setConfigurationString("inputPath=" + getClass().getResource("ind_input.json").getFile()); FIND2Configuration config = FIND2Configuration.builder() .resultReceiver(resultReceiver) .validationParameters(validationParameters) .inclusionDependencyParameters(inclusionDependencyParameters) .startK(2) .build(); FIND2 find2 = new FIND2(config); find2.execute(); assertTrue(resultReceiver.getReceivedResults().containsAll(maximumINDs)); assertTrue(maximumINDs.containsAll(resultReceiver.getReceivedResults())); }
@Test void testHypercliqueOnHigherAryEdges() throws Exception { String relationName = "TEST"; List<String> columnNames = asList("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N"); List<ColumnIdentifier> ci = new ArrayList<>(); for (String c : columnNames) { ci.add(new ColumnIdentifier(relationName, c)); } List<ExIND> maximumINDs = new ArrayList<>(); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(0), ci.get(1), ci.get(3), ci.get(4)), new ColumnPermutation(ci.get(7), ci.get(8), ci.get(10), ci.get(11)))); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(0), ci.get(2), ci.get(3), ci.get(4)), new ColumnPermutation(ci.get(7), ci.get(9), ci.get(10), ci.get(11)))); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(1), ci.get(2), ci.get(3)), new ColumnPermutation(ci.get(8), ci.get(9), ci.get(10)))); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(1), ci.get(2), ci.get(4)), new ColumnPermutation(ci.get(8), ci.get(9), ci.get(11)))); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(3), ci.get(5), ci.get(6)), new ColumnPermutation(ci.get(10), ci.get(12), ci.get(13)))); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(4), ci.get(5)), new ColumnPermutation(ci.get(11), ci.get(12)))); maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(4), ci.get(6)), new ColumnPermutation(ci.get(11), ci.get(13)))); testDatabase = TestDatabase.builder() .resourceClass(FIND2Test.class) .relationName(relationName) .columnNames(columnNames) .csvPath("testHypercliqueOnHigherAryEdges.csv") .build(); testDatabase.setUp(); InclusionDependencyResultReceiverStub resultReceiver = new InclusionDependencyResultReceiverStub(); ValidationParameters validationParameters = new ValidationParameters(); validationParameters.setQueryType(QueryType.NOT_IN); validationParameters.setConnectionGenerator(testDatabase.asConnectionGenerator()); InclusionDependencyParameters inclusionDependencyParameters = new InclusionDependencyParameters(); inclusionDependencyParameters.setAlgorithmType(AlgorithmType.FILE); inclusionDependencyParameters .setConfigurationString("inputPath=" + getClass().getResource("ind_input.json").getFile()); FIND2Configuration config = FIND2Configuration.builder() .resultReceiver(resultReceiver) .validationParameters(validationParameters) .inclusionDependencyParameters(inclusionDependencyParameters) .startK(2) .build(); FIND2 find2 = new FIND2(config); find2.execute(); assertTrue(resultReceiver.getReceivedResults().containsAll(maximumINDs)); assertTrue(maximumINDs.containsAll(resultReceiver.getReceivedResults())); }
@Test void testIrreducibleGraph() throws Exception { String relationName = "IRREDUCIBLE"; List<String> columnNames = asList( "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R"); List<ColumnIdentifier> ci = new ArrayList<>(); for (String c : columnNames) { ci.add(new ColumnIdentifier(relationName, c)); } List<ExIND> maximumINDs = new ArrayList<>(); for (int i = 0; i < 3; i++) { for (int j = 3; j < 9; j++) { maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(i), ci.get(j)), new ColumnPermutation(ci.get(i + 9), ci.get(j + 9)))); } } for (int i = 3; i < 6; i++) { for (int j = 6; j < 9; j++) { maximumINDs.add( new ExIND( new ColumnPermutation(ci.get(i), ci.get(j)), new ColumnPermutation(ci.get(i + 9), ci.get(j + 9)))); } } testDatabase = TestDatabase.builder() .resourceClass(FIND2Test.class) .relationName(relationName) .columnNames(columnNames) .csvPath("testIrreducibleExample.csv") .build(); testDatabase.setUp(); InclusionDependencyResultReceiverStub resultReceiver = new InclusionDependencyResultReceiverStub(); ValidationParameters validationParameters = new ValidationParameters(); validationParameters.setQueryType(QueryType.NOT_IN); validationParameters.setConnectionGenerator(testDatabase.asConnectionGenerator()); InclusionDependencyParameters inclusionDependencyParameters = new InclusionDependencyParameters(); inclusionDependencyParameters.setAlgorithmType(AlgorithmType.FILE); inclusionDependencyParameters .setConfigurationString( "inputPath=" + getClass().getResource("ind_input_irreducible.json").getFile()); FIND2Configuration config = FIND2Configuration.builder() .resultReceiver(resultReceiver) .validationParameters(validationParameters) .inclusionDependencyParameters(inclusionDependencyParameters) .startK(2) .build(); FIND2 find2 = new FIND2(config); find2.execute(); assertTrue(maximumINDs.containsAll(resultReceiver.getReceivedResults())); assertTrue(resultReceiver.getReceivedResults().containsAll(maximumINDs)); }