Cliques
=======

>>> import networkx as NX
>>> from networkx.generators.degree_seq import *
>>> from networkx.generators.random_graphs import *
>>> from networkx.cliques import *
>>> from networkx.operators import convert_node_labels_to_integers as cnlti

>>> z=[3,4,3,4,2,4,2,1,1,1,1]
>>> G=cnlti(NX.generators.havel_hakimi_graph(z),first_label=1)

>>> cl=find_cliques(G)
>>> cl
[[2, 6, 1, 3], [2, 6, 4], [5, 4, 7], [8, 9], [10, 11]]
>>> graph_clique_number(G)
4
>>> graph_clique_number(G,cliques=cl)
4

>>> graph_number_of_cliques(G)
5
>>> graph_number_of_cliques(G,cliques=cl)
5

>>> node_clique_number(G,1)
4
>>> node_clique_number(G,[1])
4
>>> node_clique_number(G,[1,2])
[4, 4]
>>> node_clique_number(G,[1,2],with_labels=True)
{1: 4, 2: 4}
>>> node_clique_number(G,1,with_labels=True)
{1: 4}
>>> node_clique_number(G,with_labels=True)
{1: 4, 2: 4, 3: 4, 4: 3, 5: 3, 6: 4, 7: 3, 8: 2, 9: 2, 10: 2, 11: 2}
>>> node_clique_number(G,with_labels=True,cliques=cl)
{1: 4, 2: 4, 3: 4, 4: 3, 5: 3, 6: 4, 7: 3, 8: 2, 9: 2, 10: 2, 11: 2}

>>> number_of_cliques(G,1)
1
>>> number_of_cliques(G,[1])
1
>>> number_of_cliques(G,[1,2])
[1, 2]
>>> number_of_cliques(G,[1,2],with_labels=True)
{1: 1, 2: 2}
>>> number_of_cliques(G,2,with_labels=True)
{2: 2}
>>> number_of_cliques(G,with_labels=True)
{1: 1, 2: 2, 3: 1, 4: 2, 5: 1, 6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1}
>>> number_of_cliques(G,with_labels=True,cliques=cl)
{1: 1, 2: 2, 3: 1, 4: 2, 5: 1, 6: 2, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1}

>>> cliques_containing_node(G,1)
[[2, 6, 1, 3]]
>>> cliques_containing_node(G,[1])
[[2, 6, 1, 3]]
>>> cliques_containing_node(G,[1,2])
[[[2, 6, 1, 3]], [[2, 6, 1, 3], [2, 6, 4]]]
>>> cliques_containing_node(G,[1,2],with_labels=True)
{1: [[2, 6, 1, 3]], 2: [[2, 6, 1, 3], [2, 6, 4]]}
>>> cliques_containing_node(G,1,with_labels=True)
{1: [[2, 6, 1, 3]]}
>>> cliques_containing_node(G,2)
[[2, 6, 1, 3], [2, 6, 4]]
>>> cliques_containing_node(G,2,cliques=cl)
[[2, 6, 1, 3], [2, 6, 4]]
>>> len(cliques_containing_node(G,with_labels=True))==11
True

>>> B=make_clique_bipartite(G)
>>> sorted(B.nodes())
[-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
>>> H=project_down(B)
>>> H.adj == G.adj
True
>>> H1=project_up(B)
>>> H1.nodes()
[1, 2, 3, 4, 5]
>>> H2=make_max_clique_graph(G)
>>> H1.adj == H2.adj
True
