Python coding for algorithms and graph problems