Standard BFS Loop
while ( ! q . empty ( ) ) { int u = q . front ( ) ; q . pop ( ) ; for ( int v = 0 ; v < V ; v ++ ) { if ( visited [ v ] == false && rGraph [ u ] [ v ] > 0 ) { q . push ( v ) ; parent [ v ] = u ; visited [ v ] = true ; } } }