Collaps arrays/ list of intergers

Jurgens de Bruin debruinjj at gmail.com
Tue Aug 19 08:54:24 EDT 2014


Hi All,

I do hope somebody can help me with the following:
I have the followings lists which represent the upper and lower value of a range/array.

a = [1,50]
b = [75,150]
c = [25,42]
d = [120,149]
e = [35,55]

What I would like to happen is that overlapping range will "collapse" to a single range meaning the above list would become:

as list a,c and e overlap they can be represented by
f = [1,55]
as list b and d overlap they can be represented by 
g = [75,150]

I have sort of got working solution using networkx and numpy and they work perfect for the above example the problem I have no is my true data set looks more like the following:

x = [135098,19854736]
y = [135098,41639553]
z = [11818998,12587339]

To give only three examples using networkx and numpy does not work as this results in memory error due to the ranges being so large.

I would appreciate any help with this.

Thanks



More information about the Python-list mailing list