Standard BFS Loop
while ( ! q . isEmpty ( ) ) { int u = q . peek ( ) ; q . remove ( ) ; for ( int v = 0 ; v < V ; v ++ ) { if ( visited [ v ] == false && rGraph [ u ] [ v ] > 0 ) { q . add ( v ) ; parent [ v ] = u ; visited [ v ] = true ; } } }