problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::critical_connections_in_a_network::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static vector< vector< int > > criticalConnections (int n, vector< vector< int > > &connections)
 
static void tarjan (int prev, int &step, vector< int > &dfn, int node, vector< unordered_set< int > > &g, vector< int > &low, vector< vector< int > > &ans)
 

详细描述

在文件 leetcode.h2948 行定义.

成员函数说明

◆ criticalConnections()

vector< vector< int > > leetcode::critical_connections_in_a_network::Solution::criticalConnections ( int  n,
vector< vector< int > > &  connections 
)
static

在文件 leetcode.cpp8211 行定义.

8211 {
8212 vector<unordered_set<int>> g(n);
8213 for(auto &conn: connections) {
8214 g[conn[0]].insert(conn[1]);
8215 g[conn[1]].insert(conn[0]);
8216 }
8217 vector<vector<int>> ans;
8218 vector dfn(n, -1);
8219 vector low(n, -1);
8220 unordered_set<int> vis;
8221 int step = 0;
8222 for(int i = 0; i < n; i++) {
8223 if(dfn[i] == -1) {
8224 step = 0;
8225 tarjan(-1, step, dfn, i, g, low, ans);
8226 }
8227 }
8228 return ans;
8229 }
static void tarjan(int prev, int &step, vector< int > &dfn, int node, vector< unordered_set< int > > &g, vector< int > &low, vector< vector< int > > &ans)
Definition: leetcode.cpp:8231

引用了 tarjan().

被这些函数引用 leetcode::critical_connections_in_a_network::TEST().

◆ tarjan()

void leetcode::critical_connections_in_a_network::Solution::tarjan ( int  prev,
int &  step,
vector< int > &  dfn,
int  node,
vector< unordered_set< int > > &  g,
vector< int > &  low,
vector< vector< int > > &  ans 
)
static

在文件 leetcode.cpp8231 行定义.

8231 {
8232 dfn[node] = step;
8233 low[node] = step;
8234 for(const auto &next: g[node]) {
8235 if(dfn[next] == -1) {
8236 tarjan(node, ++step, dfn, next, g, low, ans);
8237 }
8238 if(next != prev) {
8239 low[node] = min(low[node], low[next]);
8240 }
8241 if(dfn[node] < low[next]) {
8242 ans.push_back({node, next});
8243 }
8244 }
8245 }

引用了 tarjan().

被这些函数引用 criticalConnections() , 以及 tarjan().


该类的文档由以下文件生成: