Skip to content

Commit 6e98192

Browse files
mhayteradamant-pwn
andauthored
Update src/graph/01_bfs.md
Co-authored-by: Oleksandr Kulkov <adamant.pwn@gmail.com>
1 parent da6fd9a commit 6e98192

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/graph/01_bfs.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,11 @@ This way the queue still remains sorted at all time.
7474
```cpp
7575
vector<int> d(n, INF);
7676
d[s] = 0;
77-
deque<int> q;
78-
q.push_front(s);
79-
while (!q.empty()) {
77+
deque<int> q = {s};
78+
while (!empty(q)) {
8079
int v = q.front();
8180
q.pop_front();
82-
for (auto edge : adj[v]) {
83-
int u = edge.first;
84-
int w = edge.second;
81+
for (auto [u, w] : adj[v]) {
8582
if (d[v] + w < d[u]) {
8683
d[u] = d[v] + w;
8784
if (w == 1)

0 commit comments

Comments
 (0)