Creating cliques from connected components using networkx
问题 I have created a graph using networkx in Python . import networkx as nx G = createGraph ('abc.csv') #My function that returns graph from file. connected_components = nx.connected_components(G) print (connected_components) <generator object connected_components at 0x00000000221EF1A8> nbr_cc = nx.number_connected_components(G) print (nbr_cc) 57215 I want to convert every connected component into a clique and then write a csv file in following manner: node1_id node2_id connected_component_id 1 2