Skip to content
Skein

shortest path in an unweighted graph

RU: кратчайший путь в невзвешенном графе

In an unweighted graph a path's length is its number of edges, so the shortest path is the one with the fewest edges. BFS solves it: keep a dist[] array and a parent[] map, then walk parent[] backward to rebuild the route.

shortcutsexpand
search
⌘K
prev piece
k
next piece
j
cycle tier
t
this menu
?