update word ladder solution using graph