A complete graph is a graph in which every pair of nodes is connected by a unique connection. A clique is a subgraph that is complete. This is equivalent to the general concept of cliques in which every person knows all the other people. The maximum clique is the clique with the most nodes. The clique number is the number of nodes in the maximum clique. Unfortunately finding the clique number takes a long time, so we will not use the complete Facebook SPAN data.
The code is in the clique_number.py
file in this book's code bundle:
import networkx as nx import dautil as dl
fb_file = dl.data.SPANFB().load() G = nx.read_edgelist(fb_file, create_using=nx.Graph(), nodetype=int)
print('Graph Clique Number', nx.graph_clique_number(G.subgraph(list(range(2048)))))
We get the following result for the partial Facebook SPAN data:
Graph Clique Number 38
graph_clique_number()
function at https://networkx.github.io/documentation/latest/reference/generated/networkx.algorithms.clique.graph_clique_number.html (retrieved October 2015)