//return: the unused candidates //b[1, 10]: cohesion factor. higher b -> more compact "cohesive" islands private Dictionary <int, VFace> constructRegionFromPackage(Package package, CartographicIsland island, Dictionary <int, VFace> startingCandidates, float b) { BoundedVoronoi islandVoronoi = island.getVoronoi(); List <CompilationUnit> cuList = package.getCompilationUnits(); List <VFace> cellMap = new List <VFace>(); Dictionary <int, VFace> newCandidates = new Dictionary <int, VFace>(); VFace startingCell = selectFromCandidates(startingCandidates, b).Value; int maxIterations = 10; int counter = 0; while (expandCountries(cuList, cellMap, newCandidates, startingCell, b) == false && counter < maxIterations) { //Debug.Log("Backtracking"); startingCell = selectFromCandidates(startingCandidates, b).Value; counter++; } island.addPackage(package); island.addPackageCells(cellMap); return(newCandidates); }