Given a graph, determine whether two nodes are connected.
Asked in the Technical Round 2 stage. Candidate coded both DFS and DSU approaches. Reported follow-up: Find the path between the two nodes with the minimum number of nodes traversed.
Implement connected(graph, node_a, node_b). graph is a dictionary mapping each node to a list of neighboring nodes in an undirected graph. Return True if both nodes belong to the same connected component, otherwise return False.
def connected(graph, node_a, node_b):