001 #define MAX 1000 002 int size; 003 int adjMatrix[MAX][MAX]; // graph structure 004 bool visited[MAX]; 005 int group[MAX]; 006 007 void visit( int currentNode, int id ){ 008 visited[currentNode] = true; 009 group[currentNode] = id; 010 011 for ( int nextNode = 0; nextNode < size; nextNode++ ){ 012 if ( !adjMatrix[currentNode][nextNode] ) continue; 013 if ( !visited[nextNode] ){ 014 visit( nextN