Check for grouping in Points with random Connections

Hey everyone!
I have a little scripting problem I am unable to wrap my head around concerning checking if points are connected.
So overall I create points at certain positions and, then randomly connect them. The points all remain in a class, which is holds a list containing all indices of the other points this point is connected to.
So since I create the connections randomly it can happen, that not all points are connected to each other, but I want that to happen.
(It also could happen, that the points have no connections, but I managed to exclude this by the method “AddConnectionsNoConnection()”)

        for (int i = 0; i < points.Count; i++)
        {
            for (int j = i + 1; j < points.Count; j++)
            {
                //method which spits out true or false
                bool currentBool = RandomBool();
                Debug.DrawLine
                (points[i].position, points[j].position, Color.yellow, 5f) ;

                if (currentBool == true)
                {
                    points[i].activeConnections.Add(j);
                    points[j].activeConnections.Add(i);
                }



            }

        }

        AddConnectionsNoConnection();

This is the code creating the random connections where “points” is a list of my custom point class.

Does anyone has an idea how I could check if the points can be all visited over connections or if they are in different “groups”? (as shown in the attached image)
And in case there are not connected groups how I can put them in seperated lists?

That might be a quite basic question, I am kind of new to scripting, but if someone could help me out with this that would be great!

This area of study is called graph theory.

https://en.wikipedia.org/wiki/Graph_theory

Check under the “problems” section for more interesting bits to google up.

One potential solution for this problem is the minimum spanning tree. Once you have those connections guaranteed, you could add additional ones to make it “more interesting”.

Ok, I wasn’t aware that I am dipping in such a huge field with that a small problem
But if I think about the next steps of what I am planning to script, I think it is worth looking a little bit in these concepts, thank you both for the answers, they are very helpful!