Given the adjacency matrix of an undirected graph with n vertices,
determine and print the number of connected components.
A connected component is a maximal subset of vertices in which every
two vertices are linked by a path.
Input:
The first line contains the natural number n. The following n lines each
contain n binary values separated by spaces, representing the adjacency matrix.
- 1 <= n <= 50
- the matrix is symmetric with 0 on the main diagonal
Output:
The program prints to standard output a single natural number: the number of connected components.
Example:
Input:
6
0 1 0 0 0 0
1 0 0 0 0 0
0 0 0 1 0 0
0 0 1 0 0 0
0 0 0 0 0 1
0 0 0 0 1 0
Output:
3