In theory this should be working flawlessly. Most functions work, except the min_cost_path one, which either takes a really long time to finish, or runs in an infinite loop somewhere. Also, need to find a way to do as little queries as possible, otherwise it's going to take a lot of time to finish.