UVa 459 - Graph Connectivity

459 - Graph Connectivity
[ 459 - Graph Connectivity]

Explanation
In this problem you have to print the number of Connected Components in a given graph. You can use Breadth-First Search or Depth-First Search algorithms in order to achieve this number.

One can also use Union-sets to find the number of connected components in the graph.

Input
4

G

E AB CE DB EC

G AG BF

Y AB CD EF FG

Output
7

2

5

21

Solutions

 * Code All the Problems