Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update ZeroOneBfs.java
  • Loading branch information
ananya-research authored Oct 1, 2025
commit 44df65aac983de0119fd9ecdf396e69ec842ea08
8 changes: 6 additions & 2 deletions src/main/java/com/thealgorithms/graph/ZeroOneBfs.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.thealgorithms.graphs;

import java.util.*;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.List;

/**
* 0-1 BFS for shortest paths on graphs with 0/1 edge weights.
Expand Down Expand Up @@ -36,7 +39,8 @@ public static int[] shortestPaths(int n, List<List<int[]>> edges, int src) {
while (!dq.isEmpty()) {
int u = dq.pollFirst();
for (int[] e : edges.get(u)) {
int v = e[0], w = e[1];
int v = e[0];
int w = e[1];
int nd = dist[u] + w;
if (nd < dist[v]) {
dist[v] = nd;
Expand Down
Loading