[SciPy-user] Splitting up and Joining Sets

Lorenzo Isella lorenzo.isella@gmail....
Tue May 27 04:58:00 CDT 2008

Dear All,
I do not know for sure whether a SciPy array is the right tool for
what I have in mind, but I would like to post this here anyhow.
Say that you have a set of elements (plain integers):
{1,2,3,4,5,6,7,8,9,10}, which can end up split into several subsets
[no element is repeated from a subset to another, I always have 10
elements as a whole]. Ordering does not matter, so {3,4,5} is the same
as {5,3,4}. and {{1,2},{7,3}} is the same as {{7,3},{2,1}}.
Now, this is what I would like to do:
(1) Given e.g. the subsets {1,4,10},{3,7,6},{5,8,2} {9} I would like
to be able to find out which sets were merged/split in a new
configuration, e.g. {1,4,10,9} ,{3,7,6},{5,8,2} (joining of two sets)
or {1,4,10},{3,7,6},{5,8} ,{9}, {2} (splitting of two sets).
(2) There then may be a more subtle case, in which the total number of
sets stays the same, but the structure of the sets changes e.g.:
{1,4,10},{3,7,6},{5,8,2} {9} ---> {1,4,10},{3,7,6},{5,8} {9,2}, which
I also would like to be able to detect, finding out which elements
left which subset to end up in another one.
(3) Even if a scipy array was not the most suitable structure to use
for these manipulations, that is the way the data are originally
manipulated in my code, so please let me know how I should convert
them into another data type (if needed at all).

Many thanks


More information about the SciPy-user mailing list