# How to test if any set of pairs contains elements of other list? no matter order of elements

I want to detect if a set of pairs, for example a={{2,5},{6,3},{1,4},{8,7}} contains a given pair, for example tabu={{4,1},{2,6}} but don´t be relevant the order inside pair (pair {i,j} is equal to {j,i}), so in this case.... YES!!! "a has an element of tabu.

That´s the only target.

So, Are there any function to do this directly?

I was thinking in a variable Tabustatus=TRue if the big contains any pair of tabu, or tabustatus=False if not contais. Ordering previously the pairs for avoid the sort issue(no matter) any similar to:

a = {{1, 2}, {4, 3}, {3, 2}, {5, 2}};
tabu = {{2, 6}, {4, 1}};
asortg = Table[Sort[a[[i]], Greater], {i, 1, Length[a]}];
asortl = Table[Sort[a[[i]], Less], {i, 1, Length[a]}];
tabusortg = Table[Sort[tabu[[i]], Greater], {i, 1, Length[tabu]}];
tabusortl = Table[Sort[tabu[[i]], Less], {i, 1, Length[tabu]}];
Print["a...........", a];
Print["a - Greater.", asortg];
Print["a - Less....", asortl];
Print["----------------------"];
Print["tabu...........", tabu];
Print["tabu - Greater.", tabusortg];
Print["tabu - Less.....", tabusortl];
Print["----------------------"];
tabustatus = False;
Do[Do[Print["i..", i, "  j..", j];If[asortl[[i]] == tabusortl[[j]], Print[asortl[[i]], " - ", tabusortl[[j]]]; tabustatus = True; Break[], False]; If[tabustatus == True, Break[]], {i, 1, Length[asortl]}]; If[tabustatus == True, Break[]], {j, 1, Length[tabu]}];
Print["Tabu Status...", tabustatus];


In this case, I would need to add any Breaks[] to exit If... Do...Do... without continue searching,... since one time one is found,... TABUSTATUS=TRUE, We don´t need to continue searching.

Any faster and less tedious alternative?

-

Or @@ (MemberQ[Sort /@ tabu, #] & /@ Sort /@ a)

@MikaIke: Not sure if you're commenting @ me, mine gives correct True for the data in that image. Other answer was not mine... – ciao Apr 19 '14 at 9:29