Python topological grouping algorithm

in a plan, there are many points and some points will be connected. Please group these points. The grouping rule is:
1) there is no connection between groups
2) there must be connections between points within groups

how to implement such a grouping?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34e63-2bf48.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34e63-2bf48.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?