[Python} Kruskal's Algorithm
\ndef findCriticalAndPseudoCriticalEdges(self, n: int, edges: List[List[int]]) -> List[List[int]]:\n\tgraph = collections.defaultdict(list)\n\t# removed- edge t
```\ndef findCriticalAndPseudoCriticalEdges(self, n: int, edges: List[List[int]]) -> List[List[int]]:\n\tgraph = collections.defaultdict(list)\n\t# removed- edge that should not be considered, parent - for DSU, (mst_w,k) - initial values\n\tdef kruskal(removed, parent, mst_w, k): \n\t\tdef find(x):\n\t\t\tif x!=parent[x]:\n\t\t\t\tparent[x]=find(parent[x])\n\t\t\treturn parent[x]\n\t\tdef union(x,y):\n\t\t\tpx,py = find(x),find(y)\n\t\t\tif px==py: return False\n\t\t\tparent[px]=py\n\t\t\treturn True\n\t\tfor _from,_to,w in sorted(edges, key=lambda x:x[2]):\n\t\t\tedge = [_from,_to,w]\n\t\t\tif edge==removed: continue\n\t\t\tif union(_from,_to):\n\t\t\t\tmst_w+=w\n\t\t\t\tk+=1\n\t\treturn mst_w if k==n else float(\'inf\')\n\tres = [[],[]]\n\t# Original MST weight by considering all edges\n\tmst_w = kruskal(None, [i for i in range(n)], 0, 1)\n\tfor i,edge in enumerate(edges):\n\t    # remove this edge and see if MST weight has increased, if yes -> critical edge\n\t\trem_w = kruskal(edge, [i for i in range(n)], 0, 1)\n\t\tif rem_w > mst_w: \n\t\t\tres[0].append(i)\n\t\telse:\n\t\t    # If hasn\'t increased, add this edge to the DSU initial values and see if MST weight remains same, if yes -> pseudo critical edge\n\t\t\tparent = [i for i in range(n)]\n\t\t\tparent[edge[0]]=edge[1]\n\t\t\tadd_w = kruskal(edge, parent, edge[2], 2)\n\t\t\tif add_w == mst_w:\n\t\t\t\tres[1].append(i)\n\treturn res\n```
[]