time. Find the cycle created by the edge, and contract the entire cycle into one vertex. Repeat for the entire Dijkstra run. This should take the same total time complexity with Dijkstra. The edges in the short
[1559. 二维网格图中探测环](https://leetcode.cn/problems/detect-cycles-in-2d-grid/) [1579. 保证图可完全遍历](https://leetcode.cn/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable/) 2 [★ 778. 水位上升的泳池中游泳](https://leetcode.cn/problems/swim-in-rising-water/)...
vector<int> res,cyc(len,0);for(inti=0; i<len; i++){if(dfs(i, graph, cyc)) cyc[i] =1;elseres.push_back(i); }returnres; }booldfs(intsrc, vector<vector<int>>& graph, vector<int>& cyc){if(cyc[src]==1)//src is in a cyclereturntrue;elseif(cyc[src]==-1)//src isn'...