Sets of all disjoint pairs of a set of even elements

Sets of all disjoint pairs of a set of even elements - Messages

#1 Posted: 3/16/2016 2:54:18 PM
frapuano

frapuano

13 likes in 115 posts.

Group: User

In this period I am getting crazy with the following problem.
It is related with the post of Ioan that dealt with the X-Y Plo issue.
Now I am at a point that I need to list all the possible pairs of a set of even elements (pair of nodes whose edges need to be doubled to turn the graph in an Eulerian one ).
For instance if I have a set of 4 elements : A,B,C,D the result should be the following:

(AB,CD)
(AC,BD)
(AD,BC)

so 3 sets of disjoint pair

and if I have a set of 6 elements : A,B,C,D,E,F the result should be the following:

AB,CD,EF
AB,CE,DF
AB,CF,DE

AC,BD,EF
AC,BE,DF
AC,BF,DE

AD,BC,EF
AD,BE,CF
AD,BF,CE

AE,BC,DF
AE,BD,CF
AE,BF,CD

AF,BC,DE
AF,BD,CE
AF,BE,CD

so 15 sets of disjoint pair and so on the nR of disjoint sets grows up quickly as the numeber of even element in the set increase.

I was trying to develop something iterative by myself ..but without succeding .
I have found in Internet a possible ricorsive algoritm here in delphi http://stackoverflow.com/questions/32493769/sets-of-all-disjoint-pairshttp://..but till now I was not able to turn it in something in Smath.

Everything looks stupid but turning it in an algorithm is becoming really challenging.
So I am bothering to know if someone less tired has an idea on how to do this.

Thanks in advance and best regards

Franco

#2 Posted: 3/17/2016 3:22:20 PM
frapuano

frapuano

13 likes in 115 posts.

Group: User

... make sense that a non numerical problem is not taken too much in consideration here around.

Franco
#3 Posted: 3/17/2016 9:02:36 PM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Hello Franco,

This is an attempt to translate in SMath (vs Matrices) the Delphi code (vs strings) you posted: output to canvas | encapsulated
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#4 Posted: 3/17/2016 9:29:50 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Franco,

You will have to collect the 2nd set pairwise.
What a monkey business [don't read that comment].
You must have a real application for justifying
to spare time on this project. The complete W truss
system was done less than 3 weeks ago.

AFAIU [As Far As I Understand].

Jean

Forum Member.sm (18 KiB) downloaded 45 time(s).
#5 Posted: 3/18/2016 3:24:08 AM
frapuano

frapuano

13 likes in 115 posts.

Group: User

@Joan

it is just a matter of intellectual challenge and because I am interested in graph theory.
The W truss is OK , the problem is to find a generalized algorithm for any structure.
To do this is necessary to solve - in a general way - the in between problem of assigned an even set of elements find a list ( or partition) of disjoint pairs that cover this set.
It is not a matter of drawing the pairs ( this is not the task ).
OK I know clearly that is a crazy way to solve the general problem ...but now I am on this path and I must arrive to an end.

@Davide

Thanks a lot for the help ..I was really melting my brain to try to do this , moreover I do not like recursive methods and I have tried continuously to develop an iterative solution ..with an apparent illusion to have found a solution.
You are really a wizard in turning something done in another language in a Smath piece of SW.

...now I can go ahead in the next steps of the general solution.

Thanks again and best regards

Franco

1 users liked this post
Davide Carpi 3/18/2016 8:20:00 AM
#6 Posted: 3/18/2016 8:35:03 AM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

You're welcome

Wrote

Thanks a lot for the help ..I was really melting my brain to try to do this , moreover I do not like recursive methods and I have tried continuously to develop an iterative solution ..with an apparent illusion to have found a solution.



In general should be always possible, however no guarantees on the complexity of the task Converting Recursion to Iteration
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Posted: 3/19/2016 12:25:51 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Thanks Davide,

Very nice "classification", will surely be useful sometimes.
Your 'for j:= ...' the construction is more than mystic.

If useful in application, can be Unested rows wise and
exploded in matrix format. For the curiosity the cyclic
rotation of vector has been added.

Cheers, Jean

Combine.sm (42 KiB) downloaded 48 time(s).
2 users liked this post
Davide Carpi 3/19/2016 3:22:00 PM, frapuano 3/19/2016 3:22:00 PM
  • New Posts New Posts
  • No New Posts No New Posts