I'd like to produce different combinations with size from 3 to N-2 of a matrix with NN size. The process takes a long time for matrices with more than 10 sizes. Please guide me on how to produce combinations faster for a matrix of size 5050. The code for more illustration is as follows.
def ProduceAllPossibleCombinationsDictionary(CurrentNetworkMatrix, number_of_combinations):
# find all possible combinations
num_combination=number_of_combinations
test_list= CurrentNetworkMatrix.columns
for j in range(len(list(combinations(test_list, num_combination)))):
controllability_combination_mean ={}
key=list(combinations(test_list, num_combination))[j]
Mat=CurrentNetworkMatrix.loc[key,key]
#produce symmetric connectivity matrix
Adj=np.triu(Mat, k=1)
adj=Adj+Adj.transpose()
netss=pd.DataFrame(adj, columns=Mat.columns, index=Mat.columns)
# sum of connections between nodes of network
m=np.sum(netss)
a=np.mean(netss)
dd11= pd.concat([pd.DataFrame(a, columns=['mean']),
pd.DataFrame(m, columns=['sum'])],
join = 'outer', axis = 1)
for i in range(num_combination):
# # append all possible cases:
c_combination_mean[key[i]]=(key, dd11.iloc[i,0])
test.append(c_combination_mean)
AllPossibleCombinationsDictionary=test
return AllPossibleCombinationsDictionary
I have tried matrices with small size and it was ok, but for matrices of large size such as 50*50 it takes more than 3 days and no result is being showed.