C++ Kruskal Algorithm explained
\n1. Assign a value to each edge. That is what going to be printed. \n2. To form a MST using Kruskals, sort edges according to their weights \n3. Perform Kruska
```\n1. Assign a value to each edge. That is what going to be printed. \n2. To form a MST using Kruskals, sort edges according to their weights \n3. Perform Kruskals. To detect Cycle use Union find.\n4. If it dosen\'t form a cycle include that edge. Since they are sorted, it is assured that we get the MST \n5. Check for critical edges by removing each edge and finding the MST. If the new MST is greater than original MST it means that removing this edge increases the MST. Hence this is a critical edge \n6. For checking pseudo critical edges, include this edge in MST formation. If new MST == original MST then this is a pseudo critcal edge. \n\n\nclass UnionFind {\npublic: \n    vector<int> parent; \n    UnionFind(int n){\n        parent.resize(n);\n        for(int i=0;i<n;i++)\n            parent[i] = i; \n    }\n    \n    int findParent(int p) {\n        return parent[p] == p ? p : parent[p] = findParent(parent[p]); \n    }\n    \n    void Union(int u , int v) {\n        int pu = findParent(u) , pv = findParent(v); \n        parent[pu] = pv;\n    }    \n};\n\nclass Solution {\npublic:    \n    static bool cmp(vector<int>&a , vector<int>&b) {\n        return a[2] < b[2]; \n    }\n    \n    vector<vector<int>> findCriticalAndPseudoCriticalEdges(int n, vector<vector<int>>& edges) {\n        vector<int> critical ,  pscritical ;\n        //1\n        for(int i=0;i<edges.size();i++)\n            edges[i].push_back(i); \n        \n        //2 \n        sort(edges.begin() , edges.end() , cmp) ;\n        \n        int mstwt = findMST(n,edges,-1,-1); //3\n        for(int i=0;i<edges.size();i++){\n            if(mstwt< findMST(n,edges,i,-1)) //5\n                critical.push_back(edges[i][3]); \n            else if(mstwt == findMST(n,edges,-1,i))  //6\n                pscritical.push_back(edges[i][3]);\n        }\n        return {critical , pscritical};         \n    }\n    \nprivate:\n    int findMST(int &n ,  vector<vector<int>>& edges , int block , int e) {\n        UnionFind uf(n); \n        int weight = 0 ;\n        if(e != -1) {\n            weight += edges[e][2]; \n            uf.Union(edges[e][0] , edges[e][1]); \n        }\n        \n        for(int i=0;i<edges.size();i++){\n            if(i == block) \n                continue; \n            if(uf.findParent(edges[i][0]) == uf.findParent(edges[i][1])) //4\n                continue; \n            uf.Union(edges[i][0] , edges[i][1]); \n            weight += edges[i][2]; \n        }\n        \n        //Check if all vertices are included then only it is MST. \n        for(int i=0;i<n;i++){\n            if(uf.findParent(i) != uf.findParent(0))\n                return INT_MAX;\n        }    \n        \n        return weight; \n    }\n    \n};\n```
['Union Find', 'C', 'C++']