FragilityCalculator { public double calcule(final Set<AuxFileFile> files) { int pathSum = 0; for (AuxFileFile auxFileFile : files) { List<String> edges = shortestPath.getPath(auxFileFile.getFileName(), auxFileFile.getFileName2()); pathSum += edges.size(); } return (double) pathSum / files.size(); } FragilityCalculator(Set<String> files, boolean addRoot);  FragilityCalculator(UndirectedGraph<String, String> graph); double calcule(final Set<AuxFileFile> files);  }
@Test public void testCalculeBuildingGraphWithoutAddingRoot() { Set<AuxFileFile> pairFiles = new HashSet<>(); pairFiles.add(new AuxFileFile("A/B/Y", "A/B/D/X")); pairFiles.add(new AuxFileFile("A/B/D/X", "A/C/E/F/Z")); pairFiles.add(new AuxFileFile("A/C/E/F/Z", "A/B/Y")); FragilityCalculator fc = new FragilityCalculator(files, false); double fragility = fc.calcule(pairFiles); Assert.assertEquals(5.3333, fragility, 0.0001); }
@Test public void testCalculeBuildingGraphAddingRoot() { Set<AuxFileFile> pairFiles = new HashSet<>(); pairFiles.add(new AuxFileFile("root/A/B/Y", "root/A/B/D/X")); pairFiles.add(new AuxFileFile("root/A/B/D/X", "root/A/C/E/F/Z")); pairFiles.add(new AuxFileFile("root/A/C/E/F/Z", "root/A/B/Y")); FragilityCalculator fc = new FragilityCalculator(files, true); double fragility = fc.calcule(pairFiles); Assert.assertEquals(5.3333, fragility, 0.0001); }