Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Ch 4. Trees and Graphs/4-1-Route-Between-Nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ bool Graph::isRoute(int x, int y){
queue<int> q;

q.push(x);

visited[x]= true;
while(!q.empty()){
int curr = q.front();
if (curr == y)
{
return true;
}
q.pop();
visited[curr]= true;
int n_size =adj[curr].size();
for (int i = 0; i < n_size; ++i)
{
if (!visited[adj[curr][i]])
{
q.push(adj[curr][i]);
visited[adj[curr][i]] = true; // we don't want to re-add the elemenets in case of a cycle
}
}
}
Expand Down