You can use SciPy's connected_components function to find connected components in an undirected graph. Here's an example:
from scipy.sparse.csgraph import connected_components
# Find connected components
n_components, labels = connected_components(adj_matrix, directed=False)
print("Number of connected components:", n_components)
print("Component labels:", labels)