Connected Components

The task is to use depth-first search to compute the number of connected components in a given undirected graph.

Given: A simple graph with n≤103 vertices in the edge list format.

Return: The number of connected components in the graph.

See Figure 1 for visual example from the sample dataset.