割点:去掉某点x,该无向图分割成两部分(及以上)
割边:去掉某条边x,该无向图分割成两部分(及以上)
时间戳:在搜索树上的遍历序号dfn
追溯值:subtree子树和非搜索树上可达的最小点
割边和割点判定
1 void tarjan(int x, int in_edge) { 2 dfn[x] = low[x] = ++num; 3 for (int i = head[x]; i; i = nex[i]) { 4 int y = ver[i]; 5 if (!dfn[y]) { 6 tarjan(y, i); 7 low[x] = min(low[x], low[y]); 8 if (low[y] > dfn[x]) 9 bridge[i] = bridge[i ^ 1] = true; 10 } else if (i != (in_edge ^ 1)) 11 low[x] = min(low[x], dfn[y]); 12 } 13 }
1 void tarjan(int x) { 2 dfn[x] = low[x] = ++num; 3 int flag = 0; 4 for (int i = head[x]; i; i = nex[i]) { 5 int y = ver[i]; 6 if (!dfn[y]) { 7 tarjan(y); 8 low[x] = min(low[x], low[y]); 9 if (low[y] >= dfn[x]) { 10 flag++; 11 if (x != 1 || flag > 1) cut[x] = true; 12 } 13 } else low[x] = min(low[x], dfn[y]); 14 } 15 }
边缩点:利用dfs进行标记编号
点缩点:%%%
https://github.com/lydrainbowcat/tedukuri/blob/master/%E9%85%8D%E5%A5%97%E5%85%89%E7%9B%98/%E6%AD%A3%E6%96%87%E5%8C%85%E5%90%AB%E7%9A%84%E7%A8%8B%E5%BA%8F%E7%89%87%E6%AE%B5/0x66%20tarjan_dcc_euler.cpp