10054 - The Necklace
added graph connectivity check