find longest and shortest Hamiltonian path in static algorithm with python and mongoDB