The goal isn’t to make sure you have memorized a graph algorithm. The goal is to identity people who can convert a scoped problem definition to code and to identify people who can convert a vague problem definition to a scoped one.
This can be beaten by brute force by memorizing a huge amount of material, but that isn’t the goal. It isn’t like the interviewers think you’ll need to implement their question in your day job.