In Section 1 of the lab, graph G is represented using an adjacency dictionary. Exercise 1 asks you to add a new vertex "X" that is adjacent to both "A" and "F", updating all endpoints[cite: 4].
Which Python snippet correctly performs this update without breaking the undirected graph invariant?
In the lab's greedy_coloring function, the forbidden colors for a vertex v are gathered using[cite: 4]:
forbidden = {coloring[u] for u in graph[v] if u in coloring}What is the purpose of the condition if u in coloring in this set comprehension?