Might have trouble understanding this:

xset = {1, 2, 3, 4}

myclist = Outer[{#1, #2} & , xset, xset]

rlist = {{1, 2}, {2, 3}, {3, 4}, {4, 1}};

slist = {{2, 1}, {3, 2}, {4, 3}, {1, 4}};

mymatch = {};

myset = Table[mytest = myclist[[n,j]];

(* select from slist, those elements for which the first term is equal to the first term in mytest*)

list1 = Select[slist,

#1[[1]] == mytest[[1]] & ];

(* select from rlist, those elements for which the second term is equal to the second term in mylist *)

list2 = Select[rlist,

#1[[2]] == mytest[[2]] & ];

(* now make a list of all the second terms in list 1 *)

common = list1[[All,2]];

(* go through list2 and select all elements for which the first term is one of the common terms *)

mymatch = Append[mymatch,

Table[Select

[list2,

#1[[1]] == common[[n]] & ],

{n, 1, Length[common]}]],

(* do this for the entire cross product of xset x xset *)

{n, 1, 4}, {j, 1, 4}];

(* remove all the NULL cases *)

DeleteDuplicates[Flatten[myset, 4]]