| RACG. |
| Input : |
| Number of D2D pairs: n |
| Inference graph: Gn = (Vn, En) |
| All complete graphs with different set of vertices belonging to Gn |
| Number of the vertices in the maximal complete graph: M |
| The set of m vertices for the jth Km: Vm,j for each j, 1 ≤ j ≤ tm |
| The joint matrix for all of the complete graphs with m vertices: MKm, 1 ≤ m ≤ M |
| Number of RBs required by vi: rbvi, 1≤ i ≤n |
| Degree of vi: dvi, 1≤ i ≤n |
| The set of vertices having been allocated RBs: VR, initially VR={ } |
| Output : |
| //RB allocation to all D2D pairs |
| 1. form = M : 1 do |
| 2. fm,i = sum of all elements at row i of MKm, 1≤i≤n; |
| 3. L= the maximum value among fm,1, fm,2, …, fm,n; |
| 4. for a = L : 1 do |
| 5. If only fm,i for vertex vi equals a |
| 6. Do RB allocation for vi; |
| 7. Else |
| 8. D = the maximum degree among the vertices with fm,i = a; |
| 9. for d =D : 1 do |
| 10. If two or more dvi’s equal to d |
| 11. Do RB allocation for vi’s in the descending order of rbvi; |
| 12. Else if two or more vertices requiring the same number of RBs |
| 13. Do RB allocation for vi’s in a random sequence; |
| 14. end for |
| 15. end for |
| 16. end for |
| //Do RB allocation for vi |
| 17. IfVR ={ } |
| 18. Allocate a new RB chunk of rbvi RB(s); |
| 19. Else ifvi is interfered with every vertex in VR |
| 20. Allocate a new RB chunk of rbvi RB(s); |
| 21. Else if there is at least one allocated RB chunk with size more than rbvi |
| 22. Allocate an allocated RB chunk with size closest to rbvi; |
| 23. Else |
| 24. Allocate an allocated RB chunk with size closest to rbvi plus extra RB(s); |
| 25. VR = VR ∪{vi}; |