mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
included referenced variable to avoid repitition
This commit is contained in:
parent
651c269317
commit
2e5c68a54e
@ -87,9 +87,9 @@ class Graph{
|
|||||||
std::map<T,bool> breadth_first_search(T src){
|
std::map<T,bool> breadth_first_search(T src){
|
||||||
std::map<T,bool> tracker;
|
std::map<T,bool> tracker;
|
||||||
|
|
||||||
for(auto const adjlist: adjacency_list){
|
for(auto const &adjlist: adjacency_list){
|
||||||
tracker[adjlist.first]=false;
|
tracker[adjlist.first]=false;
|
||||||
for(auto const node:adjacency_list[adjlist.first]){
|
for(auto const &node:adjacency_list[adjlist.first]){
|
||||||
tracker[node]=false;
|
tracker[node]=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ class Graph{
|
|||||||
while(!q.empty()){
|
while(!q.empty()){
|
||||||
T node = q.front();
|
T node = q.front();
|
||||||
q.pop();
|
q.pop();
|
||||||
for(T const neighbour : adjacency_list[node]){
|
for(T const &neighbour : adjacency_list[node]){
|
||||||
if(!tracker[neighbour]){
|
if(!tracker[neighbour]){
|
||||||
q.push(neighbour);
|
q.push(neighbour);
|
||||||
tracker[neighbour]=true;
|
tracker[neighbour]=true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user