fork download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. /**
  7.  * Checks if node is adj to all nodes in subgraph.
  8.  *
  9.  * @param node the node to check for adjacency all other nodes in the subgraph
  10.  * @param subgraph an array of node integers
  11.  * @param len the length of the subgraph array
  12.  * @param adj a function accepting two integers corresponding to nodes and returns
  13.  * whether they are adjacent
  14.  * @returns whether node is adjacent to all nodes in subgraph.
  15.  */
  16. inline unsigned adj_all(unsigned node, const unsigned *subgraph, unsigned len, const unsigned *adj, unsigned row_len) {
  17. if (node < len)
  18. return 0;
  19.  
  20. for(unsigned i = 0; i < len; i++){
  21. if (!adj[(row_len*subgraph[i])+node])
  22. return 0;
  23. }
  24. return 1;
  25. }
  26.  
  27. /**
  28.  * Finds the size of the maximal clique in the graph.
  29.  *
  30.  * @param num_nodes the number of nodes
  31.  * @param adj a function accepting two integers corresponding to nodes and returns
  32.  * whether they are adjacent
  33.  * @returns the size of the maximal clique.
  34.  */
  35. unsigned max_clique(unsigned num_nodes, const unsigned *adj) {
  36. // Holds indices into nodes of current clique. Permuted to check every subgraph.
  37. // The stack is kept in sorted order (solely by nature of how it is incremented/permuted) so
  38. // as to only check each subgraph once.
  39. unsigned stack[num_nodes + 1];
  40. stack[0] = 0;
  41.  
  42. // Holds the current index in the stack to permute.
  43. unsigned index = 0;
  44.  
  45. // Holds the size of the largest clique found.
  46. unsigned max_len = 0;
  47.  
  48. for (;;) {
  49. // Down the tree. Add new nodes to the stack while we can find a neighbor to the
  50. // top node on the stack that is also adjacent to all nodes in the stack.
  51. again:
  52. // Find a neighbor.
  53. for (unsigned offset = 1; stack[index] + offset < num_nodes; offset++) {
  54. if (adj_all(stack[index] + offset, stack, index + 1, adj, num_nodes)) {
  55. stack[index + 1] = stack[index] + offset; // Add this node to the stack.
  56. index++;
  57. goto again;
  58. }
  59. }
  60.  
  61. if (index + 1 > max_len)
  62. max_len = index + 1;
  63.  
  64. for (;;) {
  65. stack[index]++;
  66. if (stack[index] >= num_nodes) {
  67. if (!index)
  68. return max_len;
  69. index--; // Pop the stack.
  70. stack[index]++;
  71. }
  72. if (adj_all(stack[index], stack, index, adj, num_nodes))
  73. break;
  74. }
  75. }
  76. }
  77.  
  78. static unsigned adj1[9][9] = {
  79. {0,1,1,1,0,0,1,1,1},
  80. {1,0,1,1,0,0,0,1,1},
  81. {1,1,0,1,1,1,0,0,1},
  82. {1,1,1,0,1,1,1,0,0},
  83. {0,0,1,1,0,1,1,0,0},
  84. {0,0,1,1,1,0,1,1,1},
  85. {1,0,0,1,1,1,0,1,1},
  86. {1,1,0,0,0,1,1,0,1},
  87. {1,1,1,0,0,1,1,1,0}};
  88.  
  89. static unsigned adj2[23][23] = {
  90. {0,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0},
  91. {0,0,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1},
  92. {1,1,0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,0,1,0},
  93. {0,1,0,0,1,1,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,0,1},
  94. {1,1,1,1,0,1,1,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,0},
  95. {0,1,1,1,1,0,1,1,0,1,1,1,0,1,1,1,0,0,1,1,1,1,1},
  96. {1,0,1,0,1,1,0,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1},
  97. {1,0,0,1,0,1,1,0,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1},
  98. {1,0,0,1,1,0,1,1,0,1,1,0,1,1,1,0,1,1,1,1,1,1,1},
  99. {1,1,0,1,1,1,0,1,1,0,1,1,0,1,1,1,0,1,0,1,1,1,1},
  100. {1,1,1,0,1,1,1,0,1,1,0,1,1,0,1,1,1,0,0,0,1,1,1},
  101. {1,1,1,0,0,1,1,1,0,1,1,0,1,1,0,1,1,1,0,0,1,1,1},
  102. {1,1,1,0,0,0,1,1,1,0,1,1,0,1,1,0,1,1,1,0,1,1,1},
  103. {1,1,1,1,0,1,0,1,1,1,0,1,1,0,1,1,0,1,1,1,0,1,1},
  104. {1,1,1,1,1,1,1,0,1,1,1,0,1,1,0,1,1,0,1,1,0,0,1},
  105. {1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,0,1,1,0,1,0,0,1},
  106. {1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,0,1,1,0,1,0,1},
  107. {1,1,1,1,1,0,0,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,0},
  108. {0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,1,1,0,1,1,1,1},
  109. {1,0,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,1,1,0,0,1,0},
  110. {0,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,1,1},
  111. {1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,0,0},
  112. {0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0}};
  113.  
  114. static unsigned adj3[41][41] = {
  115. {0,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,0,1,1,1,1,1,1,1,1,0,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1},
  116. {1,0,1,1,1,1,1,1,1,1,0,1,1,0,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,1,1,1},
  117. {1,1,0,1,1,1,1,1,1,0,1,0,1,1,0,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,0,1,0,1,1,1,1,1,1},
  118. {1,1,1,0,1,1,1,1,1,1,0,1,0,1,1,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,0,1,0,1,1,1,1,1},
  119. {1,1,1,1,0,1,1,1,1,0,1,0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,0,0,1,1,1,0,0,1,0,1,0,1,1,1,1},
  120. {1,1,1,1,1,0,1,1,1,1,0,1,0,1,1,0,0,1,1,0,0,0,1,1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,0,1,1,0,1,1,1,1,1,0,1},
  263. {1,1,1,1,0,0,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,0,1,1,0,1,0,0,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1,0}};
  264.  
  265. int main() {
  266. cout << max_clique(9, &adj1[0][0]) << endl;
  267. cout << max_clique(23, &adj2[0][0]) << endl;
  268. cout << max_clique(41, &adj3[0][0]) << endl;
  269. cout << max_clique(51, &adj4[0][0]) << endl;
  270. cout << max_clique(53, &adj5[0][0]) << endl;
  271. return 0;
  272. }
Success #stdin #stdout 0.31s 3488KB
stdin
Standard input is empty
stdout
4
8
9
11
13