C++ Reference

C++ Reference: Graph

cliques.h
Go to the documentation of this file.
1 // Copyright 2010-2022 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 //
15 // Maximal clique algorithms, based on the Bron-Kerbosch algorithm.
16 // See http://en.wikipedia.org/wiki/Bron-Kerbosch_algorithm
17 // and
18 // C. Bron and J. Kerbosch, Joep, "Algorithm 457: finding all cliques of an
19 // undirected graph", CACM 16 (9): 575-577, 1973.
20 // http://dl.acm.org/citation.cfm?id=362367&bnc=1.
21 //
22 // Keywords: undirected graph, clique, clique cover, Bron, Kerbosch.
23 
24 #ifndef OR_TOOLS_GRAPH_CLIQUES_H_
25 #define OR_TOOLS_GRAPH_CLIQUES_H_
26 
27 #include <cstdint>
28 #include <functional>
29 #include <limits>
30 #include <numeric>
31 #include <string>
32 #include <vector>
33 
34 #include "absl/strings/str_cat.h"
35 #include "ortools/base/int_type.h"
36 #include "ortools/base/logging.h"
37 #include "ortools/base/strong_vector.h"
38 #include "ortools/util/time_limit.h"
39 
40 namespace operations_research {
41 
42 // Finds all maximal cliques, even of size 1, in the
43 // graph described by the graph callback. graph->Run(i, j) indicates
44 // if there is an arc between i and j.
45 // This function takes ownership of 'callback' and deletes it after it has run.
46 // If 'callback' returns true, then the search for cliques stops.
47 void FindCliques(std::function<bool(int, int)> graph, int node_count,
48  std::function<bool(const std::vector<int>&)> callback);
49 
50 // Covers the maximum number of arcs of the graph with cliques. The graph
51 // is described by the graph callback. graph->Run(i, j) indicates if
52 // there is an arc between i and j.
53 // This function takes ownership of 'callback' and deletes it after it has run.
54 // It calls 'callback' upon each clique.
55 // It ignores cliques of size 1.
56 void CoverArcsByCliques(std::function<bool(int, int)> graph, int node_count,
57  std::function<bool(const std::vector<int>&)> callback);
58 
59 // Possible return values of the callback for reporting cliques. The returned
60 // value determines whether the algorithm will continue the search.
61 enum class CliqueResponse {
62  // The algorithm will continue searching for other maximal cliques.
63  CONTINUE,
64  // The algorithm will stop the search immediately. The search can be resumed
65  // by calling BronKerboschAlgorithm::Run (resp. RunIterations) again.
66  STOP
67 };
68 
69 // The status value returned by BronKerboschAlgorithm::Run and
70 // BronKerboschAlgorithm::RunIterations.
72  // The algorithm has enumerated all maximal cliques.
73  COMPLETED,
74  // The search algorithm was interrupted either because it reached the
75  // iteration limit or because the clique callback returned
76  // CliqueResponse::STOP.
78 };
79 
80 // Implements the Bron-Kerbosch algorithm for finding maximal cliques.
81 // The graph is represented as a callback that gets two nodes as its arguments
82 // and it returns true if and only if there is an arc between the two nodes. The
83 // cliques are reported back to the user using a second callback.
84 //
85 // Typical usage:
86 // auto graph = [](int node1, int node2) { return true; };
87 // auto on_clique = [](const std::vector<int>& clique) {
88 // LOG(INFO) << "Clique!";
89 // };
90 //
91 // BronKerboschAlgorithm<int> bron_kerbosch(graph, num_nodes, on_clique);
92 // bron_kerbosch.Run();
93 //
94 // or:
95 //
96 // BronKerboschAlgorithm bron_kerbosch(graph, num_nodes, clique);
97 // bron_kerbosch.RunIterations(kMaxNumIterations);
98 //
99 // This is a non-recursive implementation of the Bron-Kerbosch algorithm with
100 // pivots as described in the paper by Bron and Kerbosch (1973) (the version 2
101 // algorithm in the paper).
102 // The basic idea of the algorithm is to incrementally build the cliques using
103 // depth-first search. During the search, the algorithm maintains two sets of
104 // candidates (nodes that are connected to all nodes in the current clique):
105 // - the "not" set - these are candidates that were already visited by the
106 // search and all the maximal cliques that contain them as a part of the
107 // current clique were already reported.
108 // - the actual candidates - these are candidates that were not visited yet, and
109 // they can be added to the clique.
110 // In each iteration, the algorithm does the first of the following actions that
111 // applies:
112 // A. If there are no actual candidates and there are candidates in the "not"
113 // set, or if all actual candidates are connected to the same node in the
114 // "not" set, the current clique can't be extended to a maximal clique that
115 // was not already reported. Return from the recursive call and move the
116 // selected candidate to the set "not".
117 // B. If there are no candidates at all, it means that the current clique can't
118 // be extended and that it is in fact a maximal clique. Report it to the user
119 // and return from the recursive call. Move the selected candidate to the set
120 // "not".
121 // C. Otherwise, there are actual candidates, extend the current clique with one
122 // of these candidates and process it recursively.
123 //
124 // To avoid unnecessary steps, the algorithm selects a pivot at each level of
125 // the recursion to guide the selection of candidates added to the current
126 // clique. The pivot can be either in the "not" set and among the actual
127 // candidates. The algorithm tries to move the pivot and all actual candidates
128 // connected to it to the set "not" as quickly as possible. This will fulfill
129 // the conditions of step A, and the search algorithm will be able to leave the
130 // current branch. Selecting a pivot that has the lowest number of disconnected
131 // nodes among the candidates can reduce the running time significantly.
132 //
133 // The worst-case maximal depth of the recursion is equal to the number of nodes
134 // in the graph, which makes the natural recursive implementation impractical
135 // for nodes with more than a few thousands of nodes. To avoid the limitation,
136 // this class simulates the recursion by maintaining a stack with the state at
137 // each level of the recursion. The algorithm then runs in a loop. In each
138 // iteration, the algorithm can do one or both of:
139 // 1. Return to the previous recursion level (step A or B of the algorithm) by
140 // removing the top state from the stack.
141 // 2. Select the next candidate and enter the next recursion level (step C of
142 // the algorithm) by adding a new state to the stack.
143 //
144 // The worst-case time complexity of the algorithm is O(3^(N/3)), and the memory
145 // complexity is O(N^2), where N is the number of nodes in the graph.
146 template <typename NodeIndex>
148  public:
149  // A callback called by the algorithm to test if there is an arc between a
150  // pair of nodes. The callback must return true if and only if there is an
151  // arc. Note that to function properly, the function must be symmetrical
152  // (represent an undirected graph).
153  using IsArcCallback = std::function<bool(NodeIndex, NodeIndex)>;
154  // A callback called by the algorithm to report a maximal clique to the user.
155  // The clique is returned as a list of nodes in the clique, in no particular
156  // order. The caller must make a copy of the vector if they want to keep the
157  // nodes.
158  //
159  // The return value of the callback controls how the algorithm continues after
160  // this clique. See the description of the values of 'CliqueResponse' for more
161  // details.
163  std::function<CliqueResponse(const std::vector<NodeIndex>&)>;
164 
165  // Initializes the Bron-Kerbosch algorithm for the given graph and clique
166  // callback function.
168  CliqueCallback clique_callback)
169  : is_arc_(std::move(is_arc)),
170  clique_callback_(std::move(clique_callback)),
171  num_nodes_(num_nodes) {}
172 
173  // Runs the Bron-Kerbosch algorithm for kint64max iterations. In practice,
174  // this is equivalent to running until completion or until the clique callback
175  // returns BronKerboschAlgorithmStatus::STOP. If the method returned because
176  // the search is finished, it will return COMPLETED; otherwise, it will return
177  // INTERRUPTED and it can be resumed by calling this method again.
179 
180  // Runs at most 'max_num_iterations' iterations of the Bron-Kerbosch
181  // algorithm. When this function returns INTERRUPTED, there is still work to
182  // be done to process all the cliques in the graph. In such case the method
183  // can be called again and it will resume the work where the previous call had
184  // stopped. When it returns COMPLETED any subsequent call to the method will
185  // resume the search from the beginning.
186  BronKerboschAlgorithmStatus RunIterations(int64_t max_num_iterations);
187 
188  // Runs at most 'max_num_iterations' iterations of the Bron-Kerbosch
189  // algorithm, until the time limit is exceeded or until all cliques are
190  // enumerated. When this function returns INTERRUPTED, there is still work to
191  // be done to process all the cliques in the graph. In such case the method
192  // can be called again and it will resume the work where the previous call had
193  // stopped. When it returns COMPLETED any subsequent call to the method will
194  // resume the search from the beginning.
195  BronKerboschAlgorithmStatus RunWithTimeLimit(int64_t max_num_iterations,
196  TimeLimit* time_limit);
197 
198  // Runs the Bron-Kerbosch algorithm for at most kint64max iterations, until
199  // the time limit is excceded or until all cliques are enumerated. In
200  // practice, running the algorithm for kint64max iterations is equivalent to
201  // running until completion or until the other stopping conditions apply. When
202  // this function returns INTERRUPTED, there is still work to be done to
203  // process all the cliques in the graph. In such case the method can be called
204  // again and it will resume the work where the previous call had stopped. When
205  // it returns COMPLETED any subsequent call to the method will resume the
206  // search from the beginning.
208  return RunWithTimeLimit(std::numeric_limits<int64_t>::max(), time_limit);
209  }
210 
211  private:
212  DEFINE_INT_TYPE(CandidateIndex, ptrdiff_t);
213 
214  // A data structure that maintains the variables of one "iteration" of the
215  // search algorithm. These are the variables that would normally be allocated
216  // on the stack in the recursive implementation.
217  //
218  // Note that most of the variables in the structure are explicitly left
219  // uninitialized by the constructor to avoid wasting resources on values that
220  // will be overwritten anyway. Most of the initialization is done in
221  // BronKerboschAlgorithm::InitializeState.
222  struct State {
223  State() {}
224  State(const State& other)
225  : pivot(other.pivot),
226  num_remaining_candidates(other.num_remaining_candidates),
227  candidates(other.candidates),
228  first_candidate_index(other.first_candidate_index),
229  candidate_for_recursion(other.candidate_for_recursion) {}
230 
231  State& operator=(const State& other) {
232  pivot = other.pivot;
233  num_remaining_candidates = other.num_remaining_candidates;
234  candidates = other.candidates;
235  first_candidate_index = other.first_candidate_index;
236  candidate_for_recursion = other.candidate_for_recursion;
237  return *this;
238  }
239 
240  // Moves the first candidate in the state to the "not" set. Assumes that the
241  // first candidate is also the pivot or a candidate disconnected from the
242  // pivot (as done by RunIteration).
243  inline void MoveFirstCandidateToNotSet() {
244  ++first_candidate_index;
245  --num_remaining_candidates;
246  }
247 
248  // Creates a human-readable representation of the current state.
249  std::string DebugString() {
250  std::string buffer;
251  absl::StrAppend(&buffer, "pivot = ", pivot,
252  "\nnum_remaining_candidates = ", num_remaining_candidates,
253  "\ncandidates = [");
254  for (CandidateIndex i(0); i < candidates.size(); ++i) {
255  if (i > 0) buffer += ", ";
256  absl::StrAppend(&buffer, candidates[i]);
257  }
258  absl::StrAppend(
259  &buffer, "]\nfirst_candidate_index = ", first_candidate_index.value(),
260  "\ncandidate_for_recursion = ", candidate_for_recursion.value());
261  return buffer;
262  }
263 
264  // The pivot node selected for the given level of the recursion.
265  NodeIndex pivot;
266  // The number of remaining candidates to be explored at the given level of
267  // the recursion; the number is computed as num_disconnected_nodes +
268  // pre_increment in the original algorithm.
269  int num_remaining_candidates;
270  // The list of nodes that are candidates for extending the current clique.
271  // This vector has the format proposed in the paper by Bron-Kerbosch; the
272  // first 'first_candidate_index' elements of the vector represent the
273  // "not" set of nodes that were already visited by the algorithm. The
274  // remaining elements are the actual candidates for extending the current
275  // clique.
276  // NOTE(user): We could store the delta between the iterations; however,
277  // we need to evaluate the impact this would have on the performance.
278  absl::StrongVector<CandidateIndex, NodeIndex> candidates;
279  // The index of the first actual candidate in 'candidates'. This number is
280  // also the number of elements of the "not" set stored at the beginning of
281  // 'candidates'.
282  CandidateIndex first_candidate_index;
283 
284  // The current position in candidates when looking for the pivot and/or the
285  // next candidate disconnected from the pivot.
286  CandidateIndex candidate_for_recursion;
287  };
288 
289  // The deterministic time coefficients for the push and pop operations of the
290  // Bron-Kerbosch algorithm. The coefficients are set to match approximately
291  // the running time in seconds on a recent workstation on the random graph
292  // benchmark.
293  // NOTE(user): PushState is not the only source of complexity in the
294  // algorithm, but non-negative linear least squares produced zero coefficients
295  // for all other deterministic counters tested during the benchmarking. When
296  // we optimize the algorithm, we might need to add deterministic time to the
297  // other places that may produce complexity, namely InitializeState, PopState
298  // and SelectCandidateIndexForRecursion.
299  static const double kPushStateDeterministicTimeSecondsPerCandidate;
300 
301  // Initializes the root state of the algorithm.
302  void Initialize();
303 
304  // Removes the top state from the state stack. This is equivalent to returning
305  // in the recursive implementation of the algorithm.
306  void PopState();
307 
308  // Adds a new state to the top of the stack, adding the node 'selected' to the
309  // current clique. This is equivalent to making a recurisve call in the
310  // recursive implementation of the algorithm.
311  void PushState(NodeIndex selected);
312 
313  // Initializes the given state. Runs the pivot selection algorithm in the
314  // state.
315  void InitializeState(State* state);
316 
317  // Returns true if (node1, node2) is an arc in the graph or if node1 == node2.
318  inline bool IsArc(NodeIndex node1, NodeIndex node2) const {
319  return node1 == node2 || is_arc_(node1, node2);
320  }
321 
322  // Selects the next node for recursion. The selected node is either the pivot
323  // (if it is not in the set "not") or a node that is disconnected from the
324  // pivot.
325  CandidateIndex SelectCandidateIndexForRecursion(State* state);
326 
327  // Returns a human-readable string representation of the clique.
328  std::string CliqueDebugString(const std::vector<NodeIndex>& clique);
329 
330  // The callback called when the algorithm needs to determine if (node1, node2)
331  // is an arc in the graph.
332  IsArcCallback is_arc_;
333 
334  // The callback called when the algorithm discovers a maximal clique. The
335  // return value of the callback controls how the algorithm proceeds with the
336  // clique search.
337  CliqueCallback clique_callback_;
338 
339  // The number of nodes in the graph.
340  const NodeIndex num_nodes_;
341 
342  // Contains the state of the aglorithm. The vector serves as an external stack
343  // for the recursive part of the algorithm - instead of using the C++ stack
344  // and natural recursion, it is implemented as a loop and new states are added
345  // to the top of the stack. The algorithm ends when the stack is empty.
346  std::vector<State> states_;
347 
348  // A vector that receives the current clique found by the algorithm.
349  std::vector<NodeIndex> current_clique_;
350 
351  // Set to true if the algorithm is active (it was not stopped by an the clique
352  // callback).
353  int64_t num_remaining_iterations_;
354 
355  // The current time limit used by the solver. The time limit is assigned by
356  // the Run methods and it can be different for each call to run.
357  TimeLimit* time_limit_;
358 };
359 
360 template <typename NodeIndex>
361 void BronKerboschAlgorithm<NodeIndex>::InitializeState(State* state) {
362  DCHECK(state != nullptr);
363  const int num_candidates = state->candidates.size();
364  int num_disconnected_candidates = num_candidates;
365  state->pivot = 0;
366  CandidateIndex pivot_index(-1);
367  for (CandidateIndex pivot_candidate_index(0);
368  pivot_candidate_index < num_candidates &&
369  num_disconnected_candidates > 0;
370  ++pivot_candidate_index) {
371  const NodeIndex pivot_candidate = state->candidates[pivot_candidate_index];
372  int count = 0;
373  for (CandidateIndex i(state->first_candidate_index); i < num_candidates;
374  ++i) {
375  if (!IsArc(pivot_candidate, state->candidates[i])) {
376  ++count;
377  }
378  }
379  if (count < num_disconnected_candidates) {
380  pivot_index = pivot_candidate_index;
381  state->pivot = pivot_candidate;
382  num_disconnected_candidates = count;
383  }
384  }
385  state->num_remaining_candidates = num_disconnected_candidates;
386  if (pivot_index >= state->first_candidate_index) {
387  std::swap(state->candidates[pivot_index],
388  state->candidates[state->first_candidate_index]);
389  ++state->num_remaining_candidates;
390  }
391 }
392 
393 template <typename NodeIndex>
394 typename BronKerboschAlgorithm<NodeIndex>::CandidateIndex
395 BronKerboschAlgorithm<NodeIndex>::SelectCandidateIndexForRecursion(
396  State* state) {
397  DCHECK(state != nullptr);
398  CandidateIndex disconnected_node_index =
399  std::max(state->first_candidate_index, state->candidate_for_recursion);
400  while (disconnected_node_index < state->candidates.size() &&
401  state->candidates[disconnected_node_index] != state->pivot &&
402  IsArc(state->pivot, state->candidates[disconnected_node_index])) {
403  ++disconnected_node_index;
404  }
405  state->candidate_for_recursion = disconnected_node_index;
406  return disconnected_node_index;
407 }
408 
409 template <typename NodeIndex>
410 void BronKerboschAlgorithm<NodeIndex>::Initialize() {
411  DCHECK(states_.empty());
412  states_.reserve(num_nodes_);
413  states_.emplace_back();
414 
415  State* const root_state = &states_.back();
416  root_state->first_candidate_index = 0;
417  root_state->candidate_for_recursion = 0;
418  root_state->candidates.resize(num_nodes_, 0);
419  std::iota(root_state->candidates.begin(), root_state->candidates.end(), 0);
420  root_state->num_remaining_candidates = num_nodes_;
421  InitializeState(root_state);
422 
423  DVLOG(2) << "Initialized";
424 }
425 
426 template <typename NodeIndex>
427 void BronKerboschAlgorithm<NodeIndex>::PopState() {
428  DCHECK(!states_.empty());
429  states_.pop_back();
430  if (!states_.empty()) {
431  State* const state = &states_.back();
432  current_clique_.pop_back();
433  state->MoveFirstCandidateToNotSet();
434  }
435 }
436 
437 template <typename NodeIndex>
438 std::string BronKerboschAlgorithm<NodeIndex>::CliqueDebugString(
439  const std::vector<NodeIndex>& clique) {
440  std::string message = "Clique: [ ";
441  for (const NodeIndex node : clique) {
442  absl::StrAppend(&message, node, " ");
443  }
444  message += "]";
445  return message;
446 }
447 
448 template <typename NodeIndex>
449 void BronKerboschAlgorithm<NodeIndex>::PushState(NodeIndex selected) {
450  DCHECK(!states_.empty());
451  DCHECK(time_limit_ != nullptr);
452  DVLOG(2) << "PushState: New depth = " << states_.size() + 1
453  << ", selected node = " << selected;
454  absl::StrongVector<CandidateIndex, NodeIndex> new_candidates;
455 
456  State* const previous_state = &states_.back();
457  const double deterministic_time =
458  kPushStateDeterministicTimeSecondsPerCandidate *
459  previous_state->candidates.size();
460  time_limit_->AdvanceDeterministicTime(deterministic_time, "PushState");
461 
462  // Add all candidates from previous_state->candidates that are connected to
463  // 'selected' in the graph to the vector 'new_candidates', skipping the node
464  // 'selected'; this node is always at the position
465  // 'previous_state->first_candidate_index', so we can skip it by skipping the
466  // element at this particular index.
467  new_candidates.reserve(previous_state->candidates.size());
468  for (CandidateIndex i(0); i < previous_state->first_candidate_index; ++i) {
469  const NodeIndex candidate = previous_state->candidates[i];
470  if (IsArc(selected, candidate)) {
471  new_candidates.push_back(candidate);
472  }
473  }
474  const CandidateIndex new_first_candidate_index(new_candidates.size());
475  for (CandidateIndex i = previous_state->first_candidate_index + 1;
476  i < previous_state->candidates.size(); ++i) {
477  const NodeIndex candidate = previous_state->candidates[i];
478  if (IsArc(selected, candidate)) {
479  new_candidates.push_back(candidate);
480  }
481  }
482 
483  current_clique_.push_back(selected);
484  if (new_candidates.empty()) {
485  // We've found a clique. Report it to the user, but do not push the state
486  // because it would be popped immediately anyway.
487  DVLOG(2) << CliqueDebugString(current_clique_);
488  const CliqueResponse response = clique_callback_(current_clique_);
489  if (response == CliqueResponse::STOP) {
490  // The number of remaining iterations will be decremented at the end of
491  // the loop in RunIterations; setting it to 0 here would make it -1 at
492  // the end of the main loop.
493  num_remaining_iterations_ = 1;
494  }
495  current_clique_.pop_back();
496  previous_state->MoveFirstCandidateToNotSet();
497  return;
498  }
499 
500  // NOTE(user): The following line may invalidate previous_state (if the
501  // vector data was re-allocated in the process). We must avoid using
502  // previous_state below here.
503  states_.emplace_back();
504  State* const new_state = &states_.back();
505  new_state->candidates.swap(new_candidates);
506  new_state->first_candidate_index = new_first_candidate_index;
507 
508  InitializeState(new_state);
509 }
510 
511 template <typename NodeIndex>
513  int64_t max_num_iterations, TimeLimit* time_limit) {
514  CHECK(time_limit != nullptr);
515  time_limit_ = time_limit;
516  if (states_.empty()) {
517  Initialize();
518  }
519  for (num_remaining_iterations_ = max_num_iterations;
520  !states_.empty() && num_remaining_iterations_ > 0 &&
521  !time_limit->LimitReached();
522  --num_remaining_iterations_) {
523  State* const state = &states_.back();
524  DVLOG(2) << "Loop: " << states_.size() << " states, "
525  << state->num_remaining_candidates << " candidate to explore\n"
526  << state->DebugString();
527  if (state->num_remaining_candidates == 0) {
528  PopState();
529  continue;
530  }
531 
532  const CandidateIndex selected_index =
533  SelectCandidateIndexForRecursion(state);
534  DVLOG(2) << "selected_index = " << selected_index;
535  const NodeIndex selected = state->candidates[selected_index];
536  DVLOG(2) << "Selected candidate = " << selected;
537 
538  NodeIndex& f = state->candidates[state->first_candidate_index];
539  NodeIndex& s = state->candidates[selected_index];
540  std::swap(f, s);
541 
542  PushState(selected);
543  }
544  time_limit_ = nullptr;
545  return states_.empty() ? BronKerboschAlgorithmStatus::COMPLETED
547 }
548 
549 template <typename NodeIndex>
551  int64_t max_num_iterations) {
552  TimeLimit time_limit(std::numeric_limits<double>::infinity());
553  return RunWithTimeLimit(max_num_iterations, &time_limit);
554 }
555 
556 template <typename NodeIndex>
558  return RunIterations(std::numeric_limits<int64_t>::max());
559 }
560 
561 template <typename NodeIndex>
562 const double BronKerboschAlgorithm<
563  NodeIndex>::kPushStateDeterministicTimeSecondsPerCandidate = 0.54663e-7;
564 } // namespace operations_research
565 
566 #endif // OR_TOOLS_GRAPH_CLIQUES_H_
BronKerboschAlgorithmStatus Run()
Definition: cliques.h:557
BronKerboschAlgorithm(IsArcCallback is_arc, NodeIndex num_nodes, CliqueCallback clique_callback)
Definition: cliques.h:167
BronKerboschAlgorithmStatus RunIterations(int64_t max_num_iterations)
Definition: cliques.h:550
BronKerboschAlgorithmStatus RunWithTimeLimit(int64_t max_num_iterations, TimeLimit *time_limit)
Definition: cliques.h:512
BronKerboschAlgorithmStatus RunWithTimeLimit(TimeLimit *time_limit)
Definition: cliques.h:207
std::function< bool(NodeIndex, NodeIndex)> IsArcCallback
Definition: cliques.h:153
std::function< CliqueResponse(const std::vector< NodeIndex > &)> CliqueCallback
Definition: cliques.h:163
void FindCliques(std::function< bool(int, int)> graph, int node_count, std::function< bool(const std::vector< int > &)> callback)
void CoverArcsByCliques(std::function< bool(int, int)> graph, int node_count, std::function< bool(const std::vector< int > &)> callback)