Find horizontally and vertically aligned sets of points
Using alignment, it's mostly a matter of heuristic (sweeping horizontally and vertically). You can also work out something similar to Hough transform here.

Using inter and intra-dot distances is also known as linkage. What you want to do can be obtained through hierarchical clustering using a single linkage distance computation. It works as follows:


you start with all your dots as (unconnected) leaves in a tree;
you test all the leaves pairs, compute their spatial distance, and connect the two leaves that yield the smallest distance;
replace these 2 leaves by only 1 leave that represents the cluster;
go back to 2 and repeat until you have only 1 leave left.


The last leave is the root of a tree that represents the hierarchical clustering result, which is also called a dendrogram.
By using single linkage, you connect each dot to the closest dot, then recursively all closest pairs of dots, etc. You can finally discard the hierarchical tree part that corresponds to the smallest distance between two different lines.