Optimization cache by @yaoli - copy

Test copy without ipdb import. Used to run clean tests on Travis.
I don't like it either. I was thinking a hash table would maybe more appropriate, but there is apparently no way to hash a graph.