added code for unreacheable vertices in shortest path algorithms