The missing reverse edge
transcript
Ana and Ben become friends. Your code stores it once. Ana sees Ben in her list. Ben does not see Ana. Two people, two different answers.
Zero and one are friends. You add one to the list of zero. Ask zero. Is one a friend? Yes. Ask one. Is zero a friend? No. The same friendship, two answers.
Add the edge at both ends. One goes in the list of zero. Zero goes in the list of one. Now both sides agree.
Undirected edge: write two entries. Directed edge: write one entry. Ask yourself which one you have.
This bug raises no error. Half the answers are still right. Only a question from one side fails. Test both directions of every edge. Then the bug cannot hide.
One missing line breaks half the answers. A test with two vertices catches it. Build it yourself in the lab. Full breakdown in the lecture.