<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arman on Medium]]></title>
        <description><![CDATA[Stories by Arman on Medium]]></description>
        <link>https://medium.com/@arplusman?source=rss-fc24acd1a93c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*u6hvOWBfMEjbB2PMsSbpGw.jpeg</url>
            <title>Stories by Arman on Medium</title>
            <link>https://medium.com/@arplusman?source=rss-fc24acd1a93c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 07:53:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arplusman/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[k-Connected vs. k-Edge-Connected Graphs: What’s the Difference?]]></title>
            <link>https://medium.com/@arplusman/k-connected-vs-k-edge-connected-graphs-whats-the-difference-e6eb6b3819ac?source=rss-fc24acd1a93c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6eb6b3819ac</guid>
            <category><![CDATA[graph]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-structure-algorithm]]></category>
            <category><![CDATA[dsa-training]]></category>
            <dc:creator><![CDATA[Arman]]></dc:creator>
            <pubDate>Sat, 20 Sep 2025 21:38:47 GMT</pubDate>
            <atom:updated>2025-09-21T09:29:00.773Z</atom:updated>
            <content:encoded><![CDATA[<p>In graph theory, two concepts often get confused, even in some textbooks: <strong>k-connected graphs</strong> and <strong>k-edge-connected graphs</strong>. They sound almost the same, but they measure different kinds of robustness in a graph.</p><p>In this article, we’ll cover:</p><ul><li>the precise definitions,</li><li>the relationship and key differences,</li><li>some useful propositions and lemmas,</li><li>and a couple of examples to build intuition.</li></ul><p>By the end, you’ll not only understand the theory but also see how these concepts show up in problem-solving (e.g., Codeforces tasks).</p><h3>Preliminaries</h3><p>Before diving into k-connectedness, let’s recall a few key definitions.</p><ul><li><strong>Separating Set (Vertex Cut):</strong> A subset of vertices of a graph (call it S) such that G-S has more than one component.</li><li><strong>Disconnecting Set:</strong> A subset of edges of a graph (call it F) such that G-F has more than one component.</li><li><strong>Articulation Point (Cut Vertex):</strong> A cut vertex of G is a vertex whose removal disconnects G.</li><li><strong>Bridge:</strong> A bridge of G is an edge whose removal disconnects G.</li><li><strong>Connectivity:</strong> The connectivity of G, written κ(G), is the minimum size of a vertex set S such that G-S is disconnected or has only one vertex.</li><li><strong>Edge-connectivity:</strong> The edge-connectivity of G, written κ’(G), is the minimum size of a disconnecting set.</li><li><strong>Degree:</strong> The degree of a vertex v in a graph G is the number of edges incident to v, except that each loop at v counts twice.</li><li><strong>δ(G), Δ(G):</strong> Minimum and maximum degree of the graph.</li><li><strong>Block:</strong> A maximal connected subgraph of G that has no cut vertex.</li><li><strong>Internally Disjoint Paths:</strong> Two paths from u to v are internally disjoint if they have no common internal vertex.</li></ul><p>Note that a separating set is a subset of vertices, but a disconnecting set is a subset of edges. Also, note that a vertex cut is a set of vertices, but a cut vertex is a single vertex.</p><h3>Bridge Tree Intuition</h3><p>A <strong>bridge tree</strong> of G compresses each 2-edge-connected component into a single node. Two such nodes are joined if the original graph had a bridge between them. This always produces a tree:</p><p>Original Graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ytXnn3FzyucMybHAf0Nm_Q.png" /><figcaption>original graph G</figcaption></figure><p>Bridge tree:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*lgVyVKyTZMXd_2qqM0xo3w.png" /><figcaption>bridge tree of graph G</figcaption></figure><p>Here, node 1 corresponds to component {1, 2, 3, 4}, node 2 to {5, 6, 7}, and node 3 to {8}.</p><h3>k-Connected and k-Edge-Connected Graphs</h3><p>Now the main players:</p><ul><li><strong>k-edge-connected graph:</strong> A graph is k-edge-connected if every disconnecting set has at least k edges, i.e., κ’(G) ≥ k.</li><li><strong>k-connected graph:</strong> A graph G is k-connected if its connectivity is at least k, i.e., κ’(G) ≥ k</li></ul><p>At first glance, these seem identical, but they capture different vulnerabilities:</p><ul><li>Vertex connectivity measures resilience to <strong>losing nodes</strong>.</li><li>Edge connectivity measures resilience to <strong>losing links</strong>.</li></ul><h3>2-Connected Graphs</h3><p>For k = 2, we get the especially important class of <strong>2-connected graphs</strong>.</p><p>For a graph G with at least three vertices, the following conditions are equivalent and characterize a 2-connected graph:</p><ul><li>G is connected, and G has no cut vertex. (based on the definition of k-connected graph)</li><li>For all x, y ∈ V(G), there are internally disjoint x, y-paths.</li><li>For all x, y ∈ V(G), there is a cycle through x and y.</li><li>δ(G)≥1, and every pair of edges in G lies on a common cycle.</li></ul><h3>Some Useful Facts</h3><ul><li><strong>Expansion Lemma.</strong> If G is a k-connected graph and G’ is obtained from G by adding a new vertex y with at least k neighbors in G, then G’ is k-connected.</li><li>Two blocks in a graph share at most one vertex.</li><li>When two blocks of G share a vertex, it must be a cut vertex of G.</li><li>Every 2-connected graph is 2-edge-connected, but the converse does not hold. For example, the graph shown below is 2-edge-connected but not 2-connected.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*zap5ilP_TakG7CgZhKlQdA.png" /></figure><ul><li>Every 2-edge-connected graph is a union of one or more 2-connected components such that each component is connected to at least another component by sharing a vertex.</li></ul><p>Note that 2-connected components decompose a graph by its edges, and 2-edge-connected components decompose a graph by its nodes. It is meaningless to say decompose a graph by its 2-connected components by vertices, although some sources use this sentence, and in that case they just mean 2-edge-connected components.</p><h3>Algorithms</h3><p>Both 2-connected and 2-edge-connected components can be found using DFS + low-link values. The idea comes from Tarjan’s algorithm. Let’s break it down.</p><p><strong>2-connected components:</strong> For finding 2-connected components of graph G, first of all we need to find bridge edges. For doing that, we run DFS on the graph G. We use the term d(u) to denote the discovery time of a node u in the DFS, and low(u) to be the minimum of d(u) and d(w) such that (t, w) is a back edge from t, where t is a descendant of u, and w is an ancestor of u. If l(v) &gt; d(u) for v a direct descendant of u, then (u, v) is a bridge.</p><pre>class Vertex {<br> public:<br> int id;<br> vector&lt;pair&lt;int, int&gt;&gt; adj;<br> bool visited = false;<br> int component = -1;<br> int d;<br> int low;<br> Vertex(int id) { this-&gt;id = id; }<br>};<br> <br>class Edge {<br> public:<br> int u;<br> int v;<br> bool is_bridge;<br>};<br> <br>int t;<br>int components_count;<br> <br>void dfs(vector&lt;Vertex&gt; &amp;g, const int &amp;u, const int &amp;parent,<br> vector&lt;Edge&gt; &amp;edges) {<br>   g[u].d = g[u].low = t++;<br>   g[u].visited = true;<br>   for (auto [v, i] : g[u].adj) {<br>     if (g[v].id == parent) {<br>       continue;<br>     }<br>     if (!g[v].visited) {<br>       dfs(g, v, u, edges);<br>       g[u].low = min(g[u].low, g[v].low);<br>       if (g[v].low &gt; g[u].d) {<br>         edges[i].is_bridge = true;<br>       }<br>     } else {<br>       g[u].low = min(g[u].low, g[v].d);<br>       }<br>   }<br>}<br> <br>void label_components(vector&lt;Vertex&gt; &amp;g, const int &amp;u, const int &amp;parent,<br> vector&lt;Edge&gt; &amp;edges) {<br>   g[u].component = components_count;<br>   for (auto [v, i] : g[u].adj) {<br>     if (g[v].id == parent) {<br>     continue;<br>     }<br>     if (!edges[i].is_bridge) {<br>       if (g[v].component == -1) {<br>         label_components(g, v, u, edges);<br>       }<br>     }<br>   }<br>}<br><br>int main() {<br> t = 0;<br> components_count = 0;<br> int n, m;<br> cin &gt;&gt; n &gt;&gt; m;<br> vector&lt;Edge&gt; edges(m);<br> vector&lt;Vertex&gt; g;<br> for (int i = 0; i &lt; n; i++) {<br>   g.emplace_back(Vertex(i));<br> }<br> for (int i = 0; i &lt; m; i++) {<br>   int u, v;<br>   cin &gt;&gt; u &gt;&gt; v;<br>   edges[i].u = u;<br>   edges[i].v = v;<br>   g[u].adj.push_back({v, i});<br>   g[v].adj.push_back({u, i});<br> }<br> dfs(g, 0, -1, edges);<br> for (int i = 0; i &lt; n; i++) {<br>   if (g[i].component == -1) {<br>     label_components(g, i, -1, edges);<br>     components_count++;<br>   }<br> }<br> vector&lt;Vertex&gt; c; // bridge tree (components tree)<br> for (int i = 0; i &lt; components_count; i++) {<br>   c.emplace_back(Vertex(i));<br> }<br> for (int i = 0; i &lt; m; i++) {<br>   Edge e = edges[i];<br>   if (e.is_bridge) {<br>     c[g[e.u].component].adj.push_back({g[e.v].component, i});<br>     c[g[e.v].component].adj.push_back({g[e.u].component, i});<br>    }<br>  }<br>}</pre><p>2-edge-connected components: Finding 2-edge-connected components is similar to finding 2-connected components except that we use the notation &quot;≥&quot; instead of &quot;&gt;&quot; when comparing low(v) and d(u). We also use an auxiliary stack to store 2-connected components.</p><pre>class Vertex {<br> public:<br>  int id;<br>  vector&lt;pair&lt;int, int&gt;&gt; adj;<br>  bool visited = false;<br>  int component = -1;<br>  int d;<br>  int low;<br>  int f = numeric_limits&lt;int&gt;::max();<br>  Vertex(int id) { this-&gt;id = id; }<br>};<br><br>class Edge {<br> public:<br>  int u;<br>  int v;<br>  bool is_bridge;<br>};<br><br>int t;<br>stack&lt;int&gt; s;<br>vector&lt;vector&lt;int&gt;&gt; bcc;<br><br>void dfs(vector&lt;Vertex&gt; &amp;g, const int &amp;u, const int &amp;parent,<br>         vector&lt;Edge&gt; &amp;edges) {<br>  g[u].d = g[u].low = t++;<br>  g[u].visited = true;<br>  for (auto [v, i] : g[u].adj) {<br>    if (g[v].id == parent) {<br>      continue;<br>    }<br>    if (g[v].f == numeric_limits&lt;int&gt;::max()) {<br>      s.emplace(i);<br>    }<br>    if (!g[v].visited) {<br>      dfs(g, v, u, edges);<br><br>      if (g[v].low &gt;= g[u].d) {<br>        vector&lt;int&gt; component;<br>        while (s.top() != i) {<br>          int x = s.top();<br>          component.emplace_back(x);<br>          s.pop();<br>        }<br>        component.emplace_back(s.top());<br>        s.pop();<br>        bcc.emplace_back(component);<br>      }<br>      g[u].low = min(g[u].low, g[v].low);<br>    } else {<br>      g[u].low = min(g[u].low, g[v].d);<br>    }<br>  }<br>  g[u].f = t++;<br>}<br><br>int main() {<br>  t = 0;<br>  s = stack&lt;int&gt;();<br>  bcc = vector&lt;vector&lt;int&gt;&gt;();<br>  int n, m;<br>  cin &gt;&gt; n &gt;&gt; m;<br>  vector&lt;Edge&gt; edges(m);<br>  vector&lt;Vertex&gt; g;<br>  for (int i = 0; i &lt; n; i++) {<br>    g.emplace_back(Vertex(i));<br>  }<br>  for (int i = 0; i &lt; m; i++) {<br>    int u, v;<br>    cin &gt;&gt; u &gt;&gt; v;<br>    edges[i].u = u;<br>    edges[i].v = v;<br>    g[u].adj.push_back({v, i});<br>    g[v].adj.push_back({u, i});<br>  }<br>  dfs(g, 0, -1, edges);<br>  for (int i = 0; i &lt; bcc.size(); i++) {<br>    for (int j = 0; j &lt; bcc[i].size(); j++) {<br>      Edge e = edges[bcc[i][j]];<br>      cout &lt;&lt; e.u &lt;&lt; &quot; &quot; &lt;&lt; e.v;<br>      if (j &lt; bcc[i].size() - 1) {<br>        cout &lt;&lt; &quot; - &quot;;<br>      }<br>    }<br>    cout &lt;&lt; endl;<br>  }<br>}</pre><h3>Practice</h3><p>Theory is only half the battle; the best way to learn graph connectivity is by solving problems. Here are some Codeforces problems that touch on bridges, articulation points, and connectivity:</p><ul><li><a href="https://codeforces.com/contest/2135/problem/C">C. By the Assignment</a></li><li><a href="https://codeforces.com/contest/652/problem/E">E. Pursuit For Artifacts</a></li><li><a href="https://codeforces.com/gym/100712">H. Bridges</a></li><li><a href="https://codeforces.com/contest/178/problem/B3">B3. Greedy Merchants</a></li><li><a href="https://codeforces.com/contest/1000/problem/E">E. We Need More Bosses</a></li><li><a href="https://codeforces.com/contest/732/problem/F">F. Tourist Reform</a></li><li><a href="https://codeforces.com/contest/700/problem/C">C. Break Up</a></li></ul><h3>References</h3><ol><li><a href="https://www.amazon.it/Introduction-Graph-Theory-2nd-ed/dp/9332549656">Introduction to Graph Theory by Douglas West</a></li><li><a href="https://www.cs.mcgill.ca/~akroit/math/compsci/Cormen%20Introduction%20to%20Algorithms.pdf"><em>Introduction to Algorithms</em> by Cormen, Leiserson, Rivest, and Stein (CLRS)</a></li><li><a href="https://www.amazon.it/Elements-Programming-Interviews-Insiders-Guide/dp/1479274836"><em>Elements of Programming Interviews: The Insider’s Guide</em> by Aziz, Prakash, and Lee</a></li><li><a href="https://codeforces.com/blog/entry/83980">Codeforces blog by ritik_patel05</a></li><li><a href="https://codeforces.com/blog/entry/83980">CMU 15–451/651: (Algorithms)</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6eb6b3819ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>