{"id":264,"date":"2026-11-13T12:36:19","date_gmt":"2026-11-13T04:36:19","guid":{"rendered":"https:\/\/hoho.live\/luda\/index.php\/2026\/11\/13\/how-tarjan-finds-bridges-and-articulation-points\/"},"modified":"2026-11-13T21:53:59","modified_gmt":"2026-11-13T13:53:59","slug":"how-tarjan-finds-bridges-and-articulation-points","status":"publish","type":"post","link":"https:\/\/hoho.live\/luda\/index.php\/2026\/11\/13\/how-tarjan-finds-bridges-and-articulation-points\/","title":{"rendered":"How Tarjan finds bridges and articulation points"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Short answer:<\/strong> A <strong>bridge<\/strong> of an undirected graph is an edge whose removal increases the number of connected components. An <strong>articulation point<\/strong> is a vertex with the same effect. One depth-first search computes a discovery time and a <strong>low<\/strong> value, the oldest discovery time reachable from the subtree by tree edges and back edges. A tree edge is a bridge when the child&#8217;s low value stays above the parent&#8217;s discovery time. The scan is <strong>\u0398(V+E)<\/strong>.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>What the problem actually asks<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">Deleting a random edge or vertex and rechecking connectivity is correct and far too slow. The depth-first tree of an undirected connected graph has a simple separation property: a subtree hangs off its parent by one tree edge, and every other edge out of the subtree is a back edge to an ancestor. If none of those back edges reaches the parent or above, the tree edge is the only connection, so it is a bridge.<\/p>\n\n\n<p class=\"wp-block-paragraph\">A vertex is an articulation point for a different comparison. The root is one when it has two or more tree-children. Any other vertex u is one when some child subtree cannot reach above u, because then u separates that subtree from the rest of the graph.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>What the algorithm guarantees<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">On an undirected graph the algorithm lists every bridge and every articulation point in \u0398(V+E) time. Low[v] is the minimum of v&#8217;s discovery time, the low values of its children, and the discovery times of vertices reached by a back edge from v. The parent edge is not a back edge. Treating it as one makes low[v] see the parent and hides every bridge.<\/p>\n\n\n<p class=\"wp-block-paragraph\">A tree edge u\u2013v, with v the child, is a bridge when low[v] &gt; disc[u]. The vertex u is an articulation point when it is the root and has two tree-children, or when it is not the root and some child v has low[v] \u2265 disc[u]. The non-strict comparison for vertices is the one that catches a subtree that can return to u and no higher. The strict comparison for edges is the one that catches a subtree that cannot return even to u.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>The working steps<\/strong><\/h4>\n\n<ol class=\"wp-block-list\">\n<li>Run depth-first search on each component. Stamp discovery times as vertices are entered. Initialize low to the discovery time.<\/li>\n<li>For each neighbor, skip nothing except the edge back to the parent. A neighbor that is an ancestor updates low by a minimum with that ancestor&#8217;s discovery time.<\/li>\n<li>A neighbor that is undiscovered is a tree child. Recurse, then minimize low with the child&#8217;s low.<\/li>\n<li>After the child returns, if low[child] &gt; disc[u], the tree edge is a bridge. If u is not the root and low[child] \u2265 disc[u], u is an articulation point.<\/li>\n<li>After the root&#8217;s adjacency list is scanned, the root is an articulation point when it grew at least two tree-children.<\/li>\n<\/ol>\n\n\n<p class=\"wp-block-paragraph\">The comparisons are for an undirected graph. A directed graph&#8217;s strong connectivity is a different partition, computed by Tarjan&#8217;s strongly connected components or by Kosaraju, and a directed bridge is defined on the condensation. Parallel undirected edges are not bridges, because the second edge still connects the endpoints. The parent-edge skip has to skip one adjacency entry, not every edge to the parent&#8217;s name, when parallel edges exist.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Approaches that look simpler and fail<\/strong><\/h4>\n\n<figure class=\"wp-block-table\">\n<table>\n<thead>\n<tr>\n<th>Approach<\/th>\n<th>Why it fails when the parent edge is treated as a back edge<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Minimize low with the parent<\/td>\n<td>The subtree appears able to climb out through the same tree edge it came in on. Real bridges are missed.<\/td>\n<\/tr>\n<tr>\n<td>Use \u2265 for a bridge<\/td>\n<td>A subtree that can climb exactly to the parent is still separated from the parent&#8217;s ancestors if it cannot climb higher. The edge to the parent is a bridge only when the climb fails entirely, which is the strict test.<\/td>\n<\/tr>\n<tr>\n<td>Use &gt; for an articulation point<\/td>\n<td>A child that can reach u and not the ancestors above u is separated from the rest of the graph by u. The non-strict test is the one that marks u.<\/td>\n<\/tr>\n<tr>\n<td>Run the undirected algorithm on directed edges<\/td>\n<td>Directed reachability is not symmetric. Strong components are the directed notion of &#8220;no single edge is the whole story,&#8221; and they need the directed algorithm.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n\n\n<p class=\"wp-block-paragraph\">Strongly connected components of a directed graph belong to Tarjan&#8217;s other algorithm or to Kosaraju. A minimum cut of edge capacity, rather than a bridge of connectivity, belongs to a flow algorithm or to Stoer-Wagner.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>A working example<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">This Python fragment marks a tree edge as a bridge when the child&#8217;s low-link is strictly greater than the parent&#8217;s discovery time. The edge 1\u20142 is the only bridge of a triangle 0-1-2 with an extra edge 1-3? Here the graph is a triangle plus a pendant: 2\u20143 is the bridge. It prints <code>2 3<\/code>.<\/p>\n\n<pre><code class=\"language-python\">adj = {0: [1, 2], 1: [0, 2], 2: [0, 1, 3], 3: [2]}\ndisc = [-1] * 4\nlow = [-1] * 4\ntime = 0\nbridges = []\n\ndef dfs(u, parent):\n    global time\n    disc[u] = low[u] = time\n    time += 1\n    for v in adj[u]:\n        if v == parent:\n            continue\n        if disc[v] &lt; 0:\n            dfs(v, u)\n            low[u] = min(low[u], low[v])\n            if low[v] &gt; disc[u]:\n                bridges.append((u, v))\n        else:\n            low[u] = min(low[u], disc[v])\n\ndfs(0, -1)\nassert bridges == [(2, 3)]\nprint(*bridges[0])\n<\/code><\/pre>\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Where it is used<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">Tarjan&#8217;s bridge and articulation-point algorithm finds the links and the routers whose removal disconnects a network. Network-vulnerability scans ask exactly that. A minimum cut can be a set of several edges; a bridge is a single edge.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>When you can drop this algorithm<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">Drop the search when the graph is directed. Use a strong-component algorithm. Keep this low-value scan for undirected bridges and articulation points, and keep the parent edge out of the back-edge update.<\/p>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n<h4 class=\"wp-block-heading\"><strong>Why this stays published<\/strong><\/h4>\n\n<p class=\"wp-block-paragraph\">We publish this so a search for bridges and articulation points returns the two different comparisons, strict for edges and non-strict for vertices. <strong>One undirected depth-first search finds every bridge and articulation point from subtree low values, using a strict test for tree edges and a non-strict test for vertices.<\/strong><\/p>\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6587\u7531 HoHo \u8207 AI \u5354\u4f5c\u6574\u7406\uff0c\u6700\u5f8c\u66f4\u65b0\u65bc 2026 \u5e74 11 \u6708 13 \u65e5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Short answer: A bridge of an undirected graph is an edge whose removal increases the number of connected components. An articulation point is a vertex with the same effect. One depth-first search computes a discovery time and a low value, the oldest discovery time reachable from the subtree by&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,32],"tags":[],"class_list":["post-264","post","type-post","status-publish","format-standard","hentry","category-algorithms","category-graphs"],"_links":{"self":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/comments?post=264"}],"version-history":[{"count":2,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/264\/revisions"}],"predecessor-version":[{"id":663,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/posts\/264\/revisions\/663"}],"wp:attachment":[{"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/media?parent=264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/categories?post=264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hoho.live\/luda\/index.php\/wp-json\/wp\/v2\/tags?post=264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}