Skip to content

simplify bridge-searching expression #1460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/graph/bridge-searching.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ Pick an arbitrary vertex of the graph $root$ and run [depth first search](depth-

Now we have to learn to check this fact for each vertex efficiently. We'll use "time of entry into node" computed by the depth first search.

So, let $\mathtt{tin}[v]$ denote entry time for node $v$. We introduce an array $\mathtt{low}$ which will let us store the node with earliest entry time found in the DFS search that a node $v$ can reach with a single edge from itself or its descendants. $\mathtt{low}[v]$ is the minimum of $\mathtt{tin}[v]$, the entry times $\mathtt{tin}[p]$ for each node $p$ that is connected to node $v$ via a back-edge $(v, p)$ and the values of $\mathtt{low}[to]$ for each vertex $to$ which is a direct descendant of $v$ in the DFS tree:
So, let $\mathtt{tin}[v]$ denote entry time for node $v$. We introduce an array $\mathtt{low}$ which will let us store the node with earliest entry time found in the DFS search that a node $v$ can reach with a single edge from itself or its descendants. $\mathtt{low}[v]$ is the minimum of $\mathtt{tin}[v]$, the entry times $\mathtt{low}[p]$ for each node $p$ that is connected to node $v$ via a back-edge $(v, p)$ and the values of $\mathtt{low}[to]$ for each vertex $to$ which is a direct descendant of $v$ in the DFS tree:

$$\mathtt{low}[v] = \min \left\{
\begin{array}{l}
\mathtt{tin}[v] \\
\mathtt{tin}[p] &\text{ for all }p\text{ for which }(v, p)\text{ is a back edge} \\
\mathtt{low}[to] &\text{ for all }to\text{ for which }(v, to)\text{ is a tree edge}
\mathtt{low}[to] &\text{ for all }to\text{ for which }(v, to)\text{ is a tree edge, whether they are descendants in the DFS tree or already visited ancestors (i.e., back-edges)}
\end{array}
\right\}$$

Expand Down Expand Up @@ -67,7 +66,7 @@ void dfs(int v, int p = -1) {
continue;
}
if (visited[to]) {
low[v] = min(low[v], tin[to]);
low[v] = min(low[v], low[to]);
} else {
dfs(to, v);
low[v] = min(low[v], low[to]);
Expand Down
Loading