Given a list of edges such that the undirected graph generated cannot have multiple edges but can have loops. How many connected components can be found?
This is best demonstrated with an example. Given this list of edges:
A -- A
A -- B
B -- C
B -- D
B -- F
G -- H
H -- I
I -- G
There are two connected components that can be found:
Is there a way to determine how many connected components can be found without actually constructing the graph?

I ended up using a depth first search approach to solving this:
This isn't a mathematical solution as I had hoped for, but it works.