def get_connected_components(graph):
list_of_components = []<EOL>component = []  <EOL>unreached = set(graph.get_all_node_ids())<EOL>to_explore = deque()<EOL>while len(unreached) > <NUM_LIT:0>:<EOL><INDENT>if len(to_explore) == <NUM_LIT:0>:<EOL><INDENT>n = unreached.pop()<EOL>unreached.add(n)<EOL>to_explore.append(n)<EOL>component = []<EOL>list_of_components.append(component)<EOL><DEDENT>while len(to_explore) > <NUM_LIT:0>:<EOL><INDENT>n = to_explore.pop()<EOL>if n in unreached:<EOL><INDENT>component.append(n)<EOL>unreached.remove(n)<EOL>nodes = graph.neighbors(n)<EOL>for n in nodes:<EOL><INDENT>if n in unreached:<EOL><INDENT>to_explore.append(n)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return list_of_components<EOL>
Finds all connected components of the graph.
    Returns a list of lists, each containing the nodes that form a connected component.
    Returns an empty list for an empty graph.