C++ Reference

C++ Reference: Graph

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