You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/graph/breadth-first-search.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -152,10 +152,10 @@ Let $d_a []$ be the array containing shortest distances obtained from the first
152
152
Now for each vertex it is easy to check whether it lies on any shortest path between $a$ and $b$:
153
153
the criterion is the condition $d_a[v] + d_b[v] = d_a[b]$.
154
154
155
-
* Find the shortestpath of even length from a source vertex $s$ to a target vertex $t$ in an unweighted graph:
155
+
* Find the shortestwalk of even length from a source vertex $s$ to a target vertex $t$ in an unweighted graph:
156
156
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.
157
157
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 shortestpath from the starting vertex $(s, 0)$ to the end vertex $(t, 0)$.
158
+
After that we run a BFS to find the shortestwalk from the starting vertex $(s, 0)$ to the end vertex $(t, 0)$.<br>**Note**: This item uses the term "_walk_" rather than a "_path_" for a reason, as the vertices may potentially repeat in the found walk in order to make its length even. The problem of finding the shortest_path_ of even length is NP-Complete in directed graphs, and[solvable in linear time](https://onlinelibrary.wiley.com/doi/abs/10.1002/net.3230140403) in undirected graphs, but with a much more involved approach.