I transposed the matrix before the loop, so it doesn't do the transpose action in every iteration. In function: getnwayCollabs()
I filtered out all the groups with no collaborations before returning the collabs list in getnwayCollabs()
I also changed my bubble sort to use the sort() function built-in to python. From my understanding, the built-in function uses an adaptive mergesort and runs at O(n*log(n))
These are the adjustments made:
getnwayCollabs()
getnwayCollabs()