lab/lab11/lab11/graphs/MazeBreadthFirstPaths.java
private void bfs() {
        // TODO: Your code here. Don't forget to update distTo, edgeTo, and marked, as well as call announce()

        // Initialize a queue
        Queue<Integer> q = new ArrayDeque<>();
        for (int v = 0; v < maze.V(); v++)
            distTo[v] = INFINITY;
        distTo[s] = 0;
        marked[s] = true;
        announce();

        // enqueue s
        q.add(s);

        while (!q.isEmpty()) {
            int v = q.remove();

            if (v == t) {
                return;
            }

            for (int w : maze.adj(v)) {
                if (!marked[w]) {
                    edgeTo[w] = v;
                    announce();
                    distTo[w] = distTo[v] + 1;
                    marked[w] = true;
                    q.add(w);
                }
            }
        }


    }
/** Conducts a breadth first search of the maze starting at the source. */
Conducts a breadth first search of the maze starting at the source.
Conducts a breadth first search of the maze starting at the source .
private void bfs() {
        Queue<Integer> q = new ArrayDeque<>();
        for (int v = 0; v < maze.V(); v++)
            distTo[v] = INFINITY;
        distTo[s] = 0;
        marked[s] = true;
        announce();
        q.add(s);
        while (!q.isEmpty()) {
            int v = q.remove();
            if (v == t) {
                return;
            }
            for (int w : maze.adj(v)) {
                if (!marked[w]) {
                    edgeTo[w] = v;
                    announce();
                    distTo[w] = distTo[v] + 1;
                    marked[w] = true;
                    q.add(w);
                }
            }
        }
    }
private void bfs ( ) { Queue < Integer > q = new ArrayDeque < > ( ) ; for ( int v = 0 ; v < maze . V ( ) ; v ++ ) distTo [ v ] = INFINITY ; distTo [ s ] = 0 ; marked [ s ] = true ; announce ( ) ; q . add ( s ) ; while ( ! q . isEmpty ( ) ) { int v = q . remove ( ) ; if ( v == t ) { return ; } for ( int w : maze . adj ( v ) ) { if ( ! marked [ w ] ) { edgeTo [ w ] = v ; announce ( ) ; distTo [ w ] = distTo [ v ] + 1 ; marked [ w ] = true ; q . add ( w ) ; } } } }
Conducts a breadth first search of the maze starting at the source.
Conducts a breadth first search of the maze starting at the source .
// TODO: Your code here. Don't forget to update distTo, edgeTo, and marked, as well as call announce() // Initialize a queue // enqueue s