Application of Koller-Megiddo algoritm