Update BFS.cpp

Fixed issue #179
This commit is contained in:
Ashwek Swamy 2019-02-17 17:58:40 +05:30 committed by GitHub
parent 8f468a9cd4
commit f77fd6fb2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,7 +30,7 @@ void graph::printgraph(){
}
void graph::bfs(int s){
bool *visited = new bool[this->v+1];
memset(visited,false,sizeof(visited));
memset(visited,false,sizeof(bool)*(this->v+1));
visited[s]=true;
list<int> q;
q.push_back(s);
@ -57,4 +57,4 @@ int main(){
//g.printgraph();
g.bfs(2);
return 0;
}
}