Skip to content

Commit

Permalink
Update 22-2.md
Browse files Browse the repository at this point in the history
1. Insert code from 22-3 that should have been here.
2. Add a special case to 22-2.f
  • Loading branch information
minarai7 authored and Jay Chen committed Nov 5, 2019
1 parent ba65349 commit 010dc7d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docs/Chap22/Problems/22-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Thus, we need only check $v.low$ versus $v.d$ to decide in constant time whether

**e.** An edge $(u, v)$ lies on a simple cycle if and only if there exists at least one path from $u$ to $v$ which doesn't contain the edge $(u, v)$, if and only if removing $(u, v)$ doesn't disconnect the graph, if and only if $(u, v)$ is not a bridge.

**f.** A edge $(u, v)$ lies on a simple cycle in an undirected graph if and only if either both of its endpoints are articulation points, or one of its endpoints is an articulation point and the other is a vertex of degree $1$. Since we can compute all articulation points in $O(E)$ and we can decide whether or not a vertex has degree $1$ in constant time, we can run the algorithm in part (d) and then decide whether each edge is a bridge in constant time, so we can find all bridges in $O(E)$ time.
**f.** A edge $(u, v)$ lies on a simple cycle in an undirected graph if and only if either both of its endpoints are articulation points, or one of its endpoints is an articulation point and the other is a vertex of degree $1$. There's also a special case where there's only one edge whose incident vertices are both degree $1$. We can check this case in constant time. Since we can compute all articulation points in $O(E)$ and we can decide whether or not a vertex has degree $1$ in constant time, we can run the algorithm in part (d) and then decide whether each edge is a bridge in constant time, so we can find all bridges in $O(E)$ time.

**g.** It is clear that every nonbridge edge is in some biconnected component, so we need to show that if $C_1$ and $C_2$ are distinct biconnected components, then they contain no common edges. Suppose to the contrary that $(u, v)$ is in both $C_1$ and $C_2$.

Expand All @@ -69,3 +69,12 @@ $$a, b, p_1, \ldots, p_k, u, q_m, \ldots, q_1, d, c, q_l , \ldots, q_{m + 1}, v,
is a simple cycle containing $(a, b)$ and $(c, d)$, a contradiction. Thus, the biconnected components form a partition.

**h.** Locate all bridge edges in $O(E)$ time using the algorithm described in part (f). Remove each bridge from $E$. The biconnected components are now simply the edges in the connected components. Assuming this has been done, run the following algorithm, which clearly runs in $O(|E|)$ where $|E|$ is the number of edges originally in $G$.

```cpp
VISIT-BCC(G, u, k)
u.color = GRAY
for each v ∈ G.Adj[u]
(u, v).bcc = k
if v.color == WHITE
VISIT-BCC(G, v, k)
```

0 comments on commit 010dc7d

Please sign in to comment.