Fixed graph matching, where algorithm did not look back into past
correctly