mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 求无向图的桥(get-bridge).cpp
This commit is contained in:
parent
741ce2b07f
commit
7f66c67824
16
.ACM-Templates/Graph/求无向图的桥(get-bridge).cpp
Normal file
16
.ACM-Templates/Graph/求无向图的桥(get-bridge).cpp
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
int dfs[MAXN], low[MAXN], tim = 0;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user