SearchForSimilarProcesses { public static double findProcessesSimilarity(BPMNDiagram search, BPMNDiagram dbDiagram, String algorithm, double... param) { if (search.getNodes().size() == 0 || dbDiagram.getNodes().size() == 0) { return 0; } Graph searchGraph = ModelParser.readModel(search); searchGraph.setIdGenerator(new IdGeneratorHelper()); searchGraph.removeEmptyNodes(); Graph dbGraph = ModelParser.readModel(dbDiagram); dbGraph.setIdGenerator(new IdGeneratorHelper()); dbGraph.removeEmptyNodes(); double netSimilarity = FindModelSimilarity.findProcessSimilarity(searchGraph, dbGraph, algorithm, param); return netSimilarity; }  static double findProcessesSimilarity(BPMNDiagram search, BPMNDiagram dbDiagram, String algorithm, double... param);  }
@Test public void testFindProcessesSimilarity_one_task_A_same_process() { try { BPMNDiagram search = read_one_task_A(); BPMNDiagram dbDiagram = read_one_task_A(); double searchResult = SearchForSimilarProcesses.findProcessesSimilarity(search, dbDiagram, "Greedy", 0.6, 0.75, 1.0, 1.0, 1.0); Assert.assertEquals(1.0, searchResult, 0.0); } catch (Exception e) { fail("Exception occurred: " + e.getMessage()); } }
@Test public void testFindProcessesSimilarity_one_task_A_diff_process() { try { BPMNDiagram search = read_one_task_A(); BPMNDiagram dbDiagram = read_one_task_B(); double searchResult = SearchForSimilarProcesses.findProcessesSimilarity(search, dbDiagram, "Greedy", 0.6, 0.75, 1.0, 1.0, 1.0); Assert.assertEquals(0.5, searchResult, 0.1); } catch (Exception e) { fail("Exception occurred: " + e.getMessage()); } }
@Test public void testFindProcessesSimilarity_different_processes() { try { BPMNDiagram search = read_two_tasks_sequence_AB(); BPMNDiagram dbDiagram = read_two_tasks_sequence_XY(); double searchResult = SearchForSimilarProcesses.findProcessesSimilarity(search, dbDiagram, "Greedy", 0.6, 0.75, 1.0, 1.0, 1.0); Assert.assertEquals(0.5, searchResult, 0.0); } catch (Exception e) { fail("Exception occurred: " + e.getMessage()); } }
@Test public void testFindProcessesSimilarity_Hungarian_one_task_A_same_process() { try { BPMNDiagram search = read_one_task_A(); BPMNDiagram dbDiagram = read_one_task_A(); double searchResult = SearchForSimilarProcesses.findProcessesSimilarity(search, dbDiagram, "Hungarian", 0.6, 0.75, 1.0, 1.0, 1.0); Assert.assertEquals(1.0, searchResult, 0.0); } catch (Exception e) { fail("Exception occurred: " + e.getMessage()); } }
@Test public void testFindProcessesSimilarity_Hungarian_different_processes() { try { BPMNDiagram search = read_two_tasks_sequence_AB(); BPMNDiagram dbDiagram = read_two_tasks_sequence_XY(); double searchResult = SearchForSimilarProcesses.findProcessesSimilarity(search, dbDiagram, "Hungarian", 0.6, 0.75, 1.0, 1.0, 1.0); Assert.assertEquals(0.5, searchResult, 0.0); } catch (Exception e) { fail("Exception occurred: " + e.getMessage()); } }
@Test public void testFindProcessesSimilarity_Hungarian_one_task_A_diff_process() { try { BPMNDiagram search = read_one_task_A(); BPMNDiagram dbDiagram = read_one_task_B(); double searchResult = SearchForSimilarProcesses.findProcessesSimilarity(search, dbDiagram, "Hungarian", 0.6, 0.75, 1.0, 1.0, 1.0); Assert.assertEquals(0.66, searchResult, 0.1); } catch (Exception e) { fail("Exception occurred: " + e.getMessage()); } }