python - Find cliques of length k in a graph -


i'm working graphs of ~200 nodes , ~3500 edges. need find cliques of graph. using networkx's enumerate_all_cliques() works fine smaller graphs of 100 nodes, runs out of memory bigger ones.

"this algorithm however, hopefully, not run out of memory since keeps candidate sublists in memory , continuously removes exhausted sublists."source code enumerate_all_cliques()

is there maybe way return generator of cliques of length k, instead of cliques, in order save memory?

it seems priority save memory rather getting cliques. in case use of networkx.find_cliques(g) satisfactory solution maximal cliques (largest complete subgraph containing given node) instead of cliques.

i compared number of lists (subgraphs) of both functions:

g = nx.erdos_renyi_graph(300,0.08) print 'all:',len(list(nx.enumerate_all_cliques(g))) print 'maximal',len(list(nx.find_cliques(g)))

all: 6087

maximal 2522

and when number of edges increases in graph difference in results gets wider.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -