Connected components via depth first graph search.