Because implementing it is the best way of studying for an exam. Yeah. Ok, I’ll go and do some work now.

Edit: Thanks to Rasmus Svensson for suggesting I store the adjacent vertices as sets.