Step 1. Bipartite Graph Construction
 Create the vertex sets X and Y;
for each message BID( ; , , ( , ), ,
( ), …, ( )) and
do
  w( ) = * ;
  for  k = 1 to   do
   w( , ) = * ;
  end for
end for
Step 2. Saturated Matching
 Adopt KM algorithm to find a saturated matching in Graph
 G; Assume that vertex is matched to vertex ;
Step 3. Relay Node Assignment
for each   do
  if  flag = true then
   if  M( ) =   then
     = ;
   else
     = ;
   end if
  end if
  result+ = w ;
end for
 Return result;
Algorithm 2: RA( , flag).