Question: I am doing a graph matrix in java and currently implementing the Breadth First Traversal The pseudocode is and the code that I currently have

I am doing a graph matrix in java and currently implementing the Breadth First Traversal

The pseudocode is

I am doing a graph matrix in java and currently implementing the

and the code that I currently have is and I got stuck on the for loop

public void BF(int s) { Queue q = new Queue(); id = 0; for(int v=1; v

q.enQueue(s); while(!q.isEmpty()) {

int v = q.deQueue(); if (visited[v] != 0) { visited[v] = ++id; for (; ; ) { } } }

}

Graph :: BF( Vertex s) Begin Queue a id = 0 for v = 1 to V visited[v] = 0 q.enQueue(s) while (not q.isEmpty()) v=q.deQueue() if (not visited[v]) visited[v] = ++id for each vertex u e adj(v) if (not visited[u]) q.enQueue(u) end for end if end while End

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!