Cliques ------- Given an undirected graph G (a set of vertices and edges), a clique C in G is a set of vertices each pair of which is joined by an edge of G. Given a graph G, you are asked to find all the cliques of G with at least 3 vertices. We restrict ourselves to graphs with at most 26 nodes that are labeled A through Z. We represent edges by words consisting of two letters, where the letters are in alphabetical order. For example, AX represents an edge, but XA does not. We represent cliques by words that list all the vertices in a clique in alphabetical order. For example, AXZ might represent a clique in some graph, but AZX could NOT be a legal clique representative. To represent a graph or a set of cliques, we list repre- sentatives of edges of the graph, or of the cliques in the set, lexicographically: that is, in dictionary order. See the examples below. Input ----- For each of several cases, a specification of a graph G as follows: A line containing the name of the graph. A line containing the number n of edges. n lines each containing nothing but a two letter word representing an edge. No edge will be repeated, and the edge representatives will be sorted lexicographically. Only the graph name line may contain any spaces. The input terminates with an end of file. Output ------ For each case, a single line containing the name of the graph exactly as input, followed by one line for each clique with 3 or more vertices. The line for a clique contains just the representative of the clique, and all the clique lines for one graph are sorted lexicographic- ally. Example Input ------- ----- TEST 1 6 AB AC AD BC BD CD TEST 2 10 AE AF BE BF BX EF EX FX XY YZ Example Output ------- ------ TEST 1 ABC ABCD ABD ACD BCD TEST 2 AEF BEF BEFX BEX BFX EFX File: cliques.txt Author: Bob Walton Date: Wed Oct 10 07:18:28 EDT 2007 The authors have placed this file in the public domain; they make no warranty and accept no liability for this file. RCS Info (may not be true date or author): $Author: walton $ $Date: 2007/10/10 11:28:01 $ $RCSfile: cliques.txt,v $ $Revision: 1.3 $