SCp program find min path in an undirected graph