OJ-Problems-Source/.ACM-Templates/Graph/get-bridge/main.cpp

15 lines
410 B
C++
Raw Normal View History

int dfs[MAXN], low[MAXN], tim = 0;
2016-08-13 23:35:41 +08:00
inline void Dfs(int u) {
dfs[u] = low[u] = ++tim;
for (Edge *p = a[u]; p; p = p->next) if (p->flag) {
if (!dfs[p->y]) {
p->opt->flag = false;
Dfs(p->y);
low[u] = min(low[u], low[p->y]);
} else low[u] = min(low[u], dfs[p->y]);
}
for (Edge *p = a[u]; p; p = p->next) if (p->opt->flag == false && low[p->y] > dfs[u]) {
p->bridge = p->opt->bridge = true;
}
}