The key to the memoization cache is too big. Have you benchmarked it with large graphs? Also, memoization strategy should be pluggable.