fixed APSP bug in Python, calculates distance in C++