UVa 459

From Algorithmist
Jump to navigation Jump to search

459 - Graph Connectivity[edit]

459 - Graph Connectivity

Explanation[edit]

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[edit]

4

G

E
AB
CE
DB
EC

G
AG
BF

Y
AB
CD
EF
FG

Output[edit]

7

2

5

21

Solutions[edit]