◀ ▲ ▶Branches / Graphtheory / Algorithm: Get All Components of a Graph
Let \(G(V,E)\) be a undirected graph. Then the following algorithm get_components(G)
obtains correctly the set of all components of \(G\) and its time complexity is \(\mathcal O(V+E)\).
Algorithm: Get All Components of a Graph
 function get_components(G):
G.unvisit_all_vertices()
C=set() # initiate empty set of all components
m=0
for v in G.V:
if not v.is_visited():
m += 1 # increase the component number
C = C.union(getCOMPONENT(G,v,m)) # obtain the mth component and add it as an element of C
# at this stage, the 'visited' argument of all vertices of the last component is marked by m.
return C # return the set of all components

Table of Contents
Proofs: 1 2
Mentioned in:
Algorithms: 1
Definitions: 2
Thank you to the contributors under CC BYSA 4.0!
 Github:

References
Bibliography
 Krumke S. O., Noltemeier H.: "Graphentheoretische Konzepte und Algorithmen", Teubner, 2005, 1st Edition