{
if (basicCTS.getTier(0).size() > 1)
{
// First reduction
ObjectArrayList structures = new ObjectArrayList();
OpenIntObjectHashMap verticesFromLastTiers = new OpenIntObjectHashMap();
fillVerticesFromLastTier(hss, structures, verticesFromLastTiers);
ObjectArrayList result = new ObjectArrayList();
findIntersectionWithFirstTier(hss, result, structures, verticesFromLastTiers);
ITier firstTier = basicCTS.getTier(0);
IVertex firstTierVertex = (IVertex) result.get(0);
firstTier.intersect(firstTierVertex.getTripletValue());
basicCTS.cleanup(0, 0);
// Unify CTS
ObjectArrayList cts = new ObjectArrayList();
cts.add(((IHyperStructure) hss.get(0)).getBasicCTS());
for (int h = 0; h < hss.size(); h++)
{
hs = (IHyperStructure) hss.get(h);
cts.add(hs.getOtherCTS());
}
unify(cts);
// Update HSS by creating new one (it must be created non-empty)
Properties statistics = new Properties();
hss = createHyperStructuresSystem(cts, statistics);
saveHSS(hssTempPathReduced, hss);
// Check if its possible to find HSS route now
route = quickFindHSSRoute(hss);
if (isValidHSSRoute(route))
{
return route;
}
// Route not found. Reduce next tier
// Basic CTS may have been changed in newly created HSS
if (!basicCTS.getPermutation().sameAs(((IHyperStructure) hss.get(0)).getBasicCTS().getPermutation()))
{
// Basic CTS changed
j = -1;
basicCTS = ((IHyperStructure) hss.get(0)).getBasicCTS();
}
}
continue;
}
ITier tier = basicCTS.getTier(j);
if (tier.size() > 1)
{
// Previous tier contains one vertex
OpenIntObjectHashMap prevTier = (OpenIntObjectHashMap) ((IHyperStructure)hss.get(0)).getTiers().get(j - 1);
IVertex prevVertex = (IVertex) prevTier.values().get(0);
if (prevVertex.hasEmptyBottomEdge())
{
// If previous vertex contains only one bottom vertex
// then we should keep that vertex (and move forward to reduce next HSS tier?)