Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

Clique

Functions for finding and manipulating cliques.

Finding the largest clique in a graph is NP-complete problem, so most of these algorithms have an exponential running time; for more information, see the Wikipedia article on the clique problem [1].

[1]clique problem:: https://en.wikipedia.org/wiki/Clique_problem
enumerate_all_cliques(G) Returns all cliques in an undirected graph.
find_cliques(G) Returns all maximal cliques in an undirected graph.
make_max_clique_graph(G[, create_using]) Returns the maximal clique graph of the given graph.
make_clique_bipartite(G[, fpos, …]) Returns the bipartite clique graph corresponding to G.
graph_clique_number(G[, cliques]) Returns the clique number of the graph.
graph_number_of_cliques(G[, cliques]) Returns the number of maximal cliques in the graph.
node_clique_number(G[, nodes, cliques]) Returns the size of the largest maximal clique containing each given node.
number_of_cliques(G[, nodes, cliques]) Returns the number of maximal cliques for each node.
cliques_containing_node(G[, nodes, cliques]) Returns a list of cliques containing the given node.