MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / BFS

Method BFS

Programs/BFS.java:29–47  ·  view source on GitHub ↗
(int source)

Source from the content-addressed store, hash-verified

27 }
28
29 public void BFS(int source) {
30 Queue<Integer> queue = new LinkedList<Integer>();
31
32 queue.add(source);
33 visited[source] = true;
34
35 while (!queue.isEmpty()) {
36
37 int currNode = queue.poll();
38 System.out.print(currNode + " ");
39
40 for (int next : this.adj[currNode]) {
41 if (!visited[next]) {
42 visited[next] = true;
43 queue.add(next);
44 }
45 }
46 }
47 }
48
49 public void BFS_end() {
50

Callers 1

mainMethod · 0.95

Calls 3

isEmptyMethod · 0.80
printMethod · 0.80
addMethod · 0.65

Tested by

no test coverage detected