Querying connected components