Skip to content

Commit 73dc9f2

Browse files
Fixes example in breadth-first-search.md
The current code can't find a path of even length from a source vertex s to a target vertex t. But, it can find a walk of even length
1 parent 3969ea6 commit 73dc9f2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/graph/breadth-first-search.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ Let $d_a []$ be the array containing shortest distances obtained from the first
152152
Now for each vertex it is easy to check whether it lies on any shortest path between $a$ and $b$:
153153
the criterion is the condition $d_a [v] + d_b [v] = d_a [b]$.
154154

155-
* Find the shortest path of even length from a source vertex $s$ to a target vertex $t$ in an unweighted graph:
155+
* Find the shortest walk of even length from a source vertex $s$ to a target vertex $t$ in an unweighted graph:
156156
For this, we must construct an auxiliary graph, whose vertices are the state $(v, c)$, where $v$ - the current node, $c = 0$ or $c = 1$ - the current parity.
157157
Any edge $(u, v)$ of the original graph in this new column will turn into two edges $((u, 0), (v, 1))$ and $((u, 1), (v, 0))$.
158-
After that we run a BFS to find the shortest path from the starting vertex $(s, 0)$ to the end vertex $(t, 0)$.
158+
After that we run a BFS to find the shortest walk from the starting vertex $(s, 0)$ to the end vertex $(t, 0)$.
159159

160160
## Practice Problems
161161

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy