Thank you for your reply, Dan.
In my current implementation, I use the following codes:
all_cliques = list(nx.enumerate_all_cliques(a_graph))
for each_clique_all_size in all_cliques :
if len(each_clique_all_size) == 4:
cli_4_list.append(sorted(each_clique_all_size))
elif len(each_clique_all_size) == 5:
cli_5_list.append(sorted(each_clique_all_size))
In this case, I only need 4-cliques and 5-cliques. Any larger cliques are not needed. However,
all_cliques = list(nx.enumerate_all_cliques(a_graph)) will return all these 6-cliques, 7-cliques, etc. This step is very time-consuming.
I hope to find a way to stop nx.enumerate_all_cliques(a_graph) prematurely so that any cliques larger than k will not be generated in the first place.
I will try the code by Dmitry to see whether it helps.
Thanks again.
YS