Algorithm/알고리즘 예제코드

[알고리즘 예제][그래프탐색]BFS

JaeKwan 2021. 7. 6. 23:17
void BFS(int node){
	bool visited[MAX] = {false};
    queue<int> q;
    q.push(node);
    visited[node] = true;
    
    while(!q.empty()){
    	int cur = q.front();
        
        for(int next=0; next<N; next++){
        	if(!visited[next] && Graph[cur][next]{
        		visited[next] = ture;
                q.push(next);
             }
          }
      }
}