Yc@sJdZddlZddlmZdZddgZdZdZdS( s Cliques. iN(tramseys)Nicholas Mancuso (nick.mancuso@gmail.com)tclique_removalt max_cliquecCs@|dkrtdntj|}t|\}}|S(sFind the Maximum Clique Finds the $O(|V|/(log|V|)^2)$ apx of maximum clique/independent set in the worst case. Parameters ---------- G : NetworkX graph Undirected graph Returns ------- clique : set The apx-maximum clique of the graph Notes ------ A clique in an undirected graph G = (V, E) is a subset of the vertex set `C \subseteq V`, such that for every two vertices in C, there exists an edge connecting the two. This is equivalent to saying that the subgraph induced by C is complete (in some cases, the term clique may also refer to the subgraph). A maximum clique is a clique of the largest possible size in a given graph. The clique number `\omega(G)` of a graph G is the number of vertices in a maximum clique in G. The intersection number of G is the smallest number of cliques that together cover all edges of G. https://en.wikipedia.org/wiki/Maximum_clique References ---------- .. [1] Boppana, R., & Halldórsson, M. M. (1992). Approximating maximum independent sets by excluding subgraphs. BIT Numerical Mathematics, 32(2), 180–196. Springer. doi:10.1007/BF01994876 sExpected NetworkX graph!N(tNonet ValueErrortnxt complementR(tGtcgraphtisett_((s~/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/approximation/clique.pyRs & cCs|j}tj|\}}|g}|g}xX|r|j|tj|\}}|rt|j|n|r6|j|q6q6Wt|dt}||fS(s Repeatedly remove cliques from the graph. Results in a $O(|V|/(\log |V|)^2)$ approximation of maximum clique and independent set. Returns the largest independent set found, along with found maximal cliques. Parameters ---------- G : NetworkX graph Undirected graph Returns ------- max_ind_cliques : (set, list) tuple Maximal independent set and list of maximal cliques (sets) in the graph. References ---------- .. [1] Boppana, R., & Halldórsson, M. M. (1992). Approximating maximum independent sets by excluding subgraphs. BIT Numerical Mathematics, 32(2), 180–196. Springer. tkey(tcopyRt ramsey_R2tremove_nodes_fromtappendtmaxtlen(Rtgraphtc_iti_itcliquestisetstmaxiset((s~/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/approximation/clique.pyR?s     ( t__doc__tnetworkxRt!networkx.algorithms.approximationRt __author__t__all__RR(((s~/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/networkx/networkx/algorithms/approximation/clique.pyts    0