{"id":752,"date":"2020-08-04T11:23:23","date_gmt":"2020-08-04T03:23:23","guid":{"rendered":"http:\/\/www.zyhcoding.club\/?p=752"},"modified":"2020-08-04T19:04:25","modified_gmt":"2020-08-04T11:04:25","slug":"tarjan%e7%ae%97%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"http:\/\/www.zyhcoding.club\/index.php\/2020\/08\/04\/tarjan%e7%ae%97%e6%b3%95%e4%bb%8b%e7%bb%8d\/","title":{"rendered":"Tarjan\u7b97\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"<h3>Tarjan\u7b97\u6cd5<\/h3>\n<p>Tarjan\u7b97\u6cd5\u662f\u7528\u6765\u6c42\u6709\u5411\u56fe\u7684\u5f3a\u8fde\u901a\u5206\u91cf\u7684\u7b97\u6cd5\uff0c\u53ef\u4ee5\u7528\u6765\u89e3\u51b3\u5272\u70b9\uff0c\u5272\u8fb9\u95ee\u9898\uff0c\u4f46\u5b83\u4eec\u5404\u81ea\u7684\u4ee3\u7801\u90fd\u6709\u4e00\u4e9b\u533a\u522b\u3002<\/p>\n<p>Tarjan\u7b97\u6cd5\u662f\u5229\u7528dfs\u6765\u8fdb\u884c\u7684\uff0c\u5b83\u7684\u8bbf\u95ee\u6b21\u5e8f\u53ef\u4ee5\u7ec4\u6210\u4e00\u9897\u641c\u7d22\u6811\uff0c\u6bcf\u4e00\u4e2a\u8fde\u901a\u5206\u91cf\u662f\u4e00\u4e2a\u5b50\u6811\u3002<br \/>\n\u5f15\u5165\u4e24\u4e2a\u6570\u7ec4\uff1a<\/p>\n<blockquote>\n<p>dfn[]: dfn[i]\u8868\u793a\u7ed3\u70b9i\u88ab\u8bbf\u95ee\u7684\u65f6\u95f4\u6233(\u6216\u8005\u5148\u540e\u6b21\u5e8f)<br \/>\nlow[]: low[u]\u4e3au\u6216u\u7684\u5b50\u6811\u4e2d\u80fd\u901a\u8fc7\u975e\u7236\u5b50\u8fb9\u8ffd\u6eaf\u5230\u7684\u6700\u65e9\u7684\u8282\u70b9<\/p>\n<\/blockquote>\n<p>\u6b65\u9aa4\uff1a<br \/>\n1.\u82e5dfs[i]==0\uff0c\u5373\u7ed3\u70b9i\u4ece\u672a\u88ab\u8bbf\u95ee\u8fc7\uff0c\u90a3\u4e48\u8bbe\u7f6e\u503cdfn[i] = low[i] = 0\uff0c\u5c06i\u5982\u6808\uff0c\u6807\u8bb0vis[i] = 1.<br \/>\n2.\u904d\u5386\u7ed3\u70b9i\u6307\u5411\u7684\u7ed3\u70b9j\uff0c\u82e5j\u6ca1\u6709\u88ab\u8bbf\u95ee\u8fc7(dfn[j]==0)\uff0c\u8bbf\u95eej(\u56de\u5230\u6b65\u9aa41)\uff0c\u66f4\u65b0\u503clow[i] = min(low[i], low[j])\uff1b\u82e5\u7ed3\u70b9j\u88ab\u8bbf\u95ee\u8fc7(dfn[j]\u6709\u503c)\uff0c\u4e14\u8fd8\u5728\u6808\u4e2d(vis[j]==1)\uff0c\u90a3\u4e48\u66f4\u65b0\u503clow[i] = min(low[i], dfn[j]).<br \/>\n3.\u904d\u5386\u5b8c\u6240\u6709i\u6307\u5411\u7684\u7ed3\u70b9\u540e\uff0c\u82e5\u6709dfn[i]==low[i]\uff0c\u90a3\u4e48\u6808\u91cc\u9762\u4ece\u6808\u9876\u5230\u7ed3\u70b9i\u4e4b\u95f4\u7684\u503c\u6784\u6210\u4e00\u4e2a\u5f3a\u8fde\u901a\u5206\u91cf\u3002\u8fde\u7eed\u51fa\u6808\u81f3i(\u7ed3\u70b9i\u4e5f\u51fa\u6808)\uff0c\u5373low[]\u503c\u76f8\u540c\u7684\u7ed3\u70b9\u6784\u6210\u4e00\u4e2a\u5f3a\u8fde\u901a\u5206\u91cf\u3002<\/p>\n<p>\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-c++\">\nvoid Tarjan(int u){\n    dfn[u] = low[u] = ++num;\n    vis[u] = 1;\n    sta.push(i);\n    for (int i=head[u]; i; i=e[i].next){\n        if (!dfn[e[i].to]){\n            Tarjan(e[i].to);\n            low[u] = min(low[u], low[e[i].to]);\n        }else if (vis[e[i].to])\n            low[u] = min(low[u], dfn[e[i].to]);\n    }\n    if (low[u]==dfn[u]){\n        while (sta.top()!=u){\n            vis[sta.top()] = 0;\n            low[sta.top()] = low[u];\n            sta.pop();\n        }\n        vis[sta.top()] = 0;\n        sta.pop();\n    }\n    return;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Tarjan\u7b97\u6cd5 Tarjan\u7b97\u6cd5\u662f\u7528\u6765\u6c42\u6709\u5411\u56fe\u7684\u5f3a\u8fde\u901a\u5206\u91cf\u7684\u7b97\u6cd5\uff0c\u53ef\u4ee5\u7528\u6765\u89e3\u51b3\u5272\u70b9\uff0c\u5272\u8fb9\u95ee\u9898\uff0c\u4f46\u5b83 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[55],"tags":[],"_links":{"self":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/752"}],"collection":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/comments?post=752"}],"version-history":[{"count":5,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/752\/revisions"}],"predecessor-version":[{"id":759,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/posts\/752\/revisions\/759"}],"wp:attachment":[{"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/media?parent=752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/categories?post=752"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.zyhcoding.club\/index.php\/wp-json\/wp\/v2\/tags?post=752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}