I'm trying to count the number of connected components (=isolated networks) in the whole network graph, but it takes much more memory and time than I expected.
I referenced the python code from https://frhyme.github.io/python-libs/nx_algorithm_clique/ and checked the similar question in the stackoverflow (Find and count the number of isolated and semi-isolated nodes in a network)
import networkx as nx
from networkx.algorithms.approximation import clique
import time
import matplotlib.pyplot as plt
N = 50
p = 0.05
G1 = networkx.fast_gnp_random_graph(N, p, seed=32)
print("== nx.enumerate_all_cliques(G1)")
clique_num = 0
for clique in networkx.enumerate_all_cliques(G1):
# clique type: list
clique_num+=1
print(f"all cliques count: {clique_num}")
print("=="*30)
The network contains about 9,800 nodes and 36,000 edges wtih high sparsity (density=0.1).
I'm sorry for lack of example network, but can anyone suggest other way for counting cliques as below?