Add a map in the class that captures the edges of each node so that future lookups of the edges don't require to look through all of the edges.