Issue 762 shortest path hide nodes edges

I add the monkey patching context manager in a separate file named ```restrictions.py```. I'm glad to hear your code reviews. About testing, I add some in the ```test_generics.py```, because I think it duplicated if I also test them in ```test_weight.py``` or ```test_unweight.py```, etc. Let me know if you have concerns about adding more tests. ;)