Remove self loops in RAG

- Removes self loops in RAG
- Handles NCut case where self loops are required

This will result in much cleaner code, as seen in #1100
I think yours will be slower, since you are creating an intermediate array, let me check.