Count no of component
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    void ne(int n,vector<vector<int>>& r, int source,vector<bool>& vd)  \n    {\n        queue<int>q;\n        q.push(source);\n        vd[source]=true;\n        while(!q.empty()){\n            int v=q.front();\n            q.pop();\n\n            vector<int> temp=r[v];\n            for(int i=0;i<temp.size();i++){\n                int vertex=temp[i];\n                if(vd[vertex]==false)\n                {\n                    q.push(vertex);\n                    vd[vertex]=true;\n                }\n                \n            }\n        }\n    }\npublic:\n    int makeConnected(int n, vector<vector<int>>& connections) {\n        \n\n        if(connections.size()<n-1)\n            return -1;\n\n        vector<vector<int>> r(n);\n    \n        for(auto i:connections){\n            r[i[0]].push_back(i[1]);\n            r[i[1]].push_back(i[0]);\n        }\n\n        int nc=0;\n\n        vector<bool> vd(n,false);\n        \n        for(int i=0;i<vd.size();i++){\n            if(vd[i]==false){\n                nc++;\n                ne(n,r,i,vd);\n            }\n        }\n        \n        cout<<nc;\n        return nc-1;\n    }\n};\n```
['C++']