How to determine set of connected line from an array in python
===

I have an array that looks something like:

[0  x1  0   0   y1   0   z1 <br/>
 0  0   x2  0   y2  0   z2  <br/>
 0  0   x3  0   0   y3  z3  <br/>
 0  0   x4  0   0   y4  z4 <br/>
 0  x5  0   0   0   y5  z5  <br/>
 0  0   0   0   y6   0   0] <br/>

I need to determine set of connected line (i.e. line that connects to the points [x1,x2,x3..], [y1,y2,y3...], [z1,z2,z3..]) from the array and then need to find maximum value in each line i.e. max{x1,x2,x3,...}, max{y1,y2,y3..} etc.  i was trying to do nearest neighbor search using kdtree but it return the same array. I have array of the size (200 x 8000). is there any easier way to do this?