### Number of line segments in a group - algorithm

Hi experts!

Im a newby SAGE, SciPy, Numpy and Python user.

I'm trying to write an algorithm that accounts for how many straight segment groups ('clusters') of a given dimension (dimension = number of lines that form the cluster).

Each line segment in my algorith is random-generated and characterized by his start point (xi,yi) and his end-point ~~(wf,yf).~~(xf,yf).

For example, in the image ~~attached (~~attached:

http://subefotos.com/ver/?8818abc218ccd909f8c0bba71446c3b5o.png

are: one cluster formed by 9 line segments, one cluster consists of four line segments, one cluster consists of five line segments, two cluster formed by three line segments, four cluster formed by two line segments and one cluster consists of one single line segments.

Until now i only could write a code that generates a matrix of NxN (where N = total number of line segments ). In this matrix, the element located in row A column B is 'True' if the segment A is cut with segment B, and its value is 'False' if that two segments are NOT intersect.

¿Any idea?

Waiting for your answers.

Thanks a lot!