![]() |
Google OR-Tools v9.12
a fast and portable software suite for combinatorial optimization
|
#include <cliques.h>
Public Member Functions | |
void | Initialize (int num_nodes) |
void | SetWeight (int i, double weight) |
void | AddEdge (int a, int b) |
Add an edge in the graph. | |
void | SetWorkLimit (int64_t limit) |
We count the number of basic operations, and stop when we reach this limit. | |
void | SetMinimumWeight (double min_weight) |
Set the minimum weight of the maximal cliques we are looking for. | |
void | TakeTransitiveClosureOfImplicationGraph () |
std::vector< std::vector< int > > | Run () |
std::vector< std::pair< int, double > > & | GetMutableIndexAndWeight () |
int64_t | WorkDone () const |
bool | HasEdge (int i, int j) const |
More specialized version used to separate clique-cuts in MIP solver. This finds all maximal clique with a weight greater than a given threshold. It also has computation limit.
This implementation assumes small graph since we use a dense bitmask representation to encode the graph adjacency. So it shouldn't really be used with more than a few thousands nodes.
|
inline |
|
inline |
|
inline |
void operations_research::WeightedBronKerboschBitsetAlgorithm::Initialize | ( | int | num_nodes | ) |
Resets the class to an empty graph will all weights of zero. This also reset the work done.
We need +1 in case the graph is complete and form a clique.
Initialize to empty graph.
Definition at line 267 of file cliques.cc.
std::vector< std::vector< int > > operations_research::WeightedBronKerboschBitsetAlgorithm::Run | ( | ) |
Runs the algo and returns all maximal clique with a weight above the configured thrheshold via SetMinimumWeight(). It is possible we reach the work limit before that.
We run an iterative DFS where we push all possible next node to queue_. We just abort brutally if we hit the work limit.
We add this node to the clique.
Choose a pivot. We use the vertex with highest weight according to: Samuel Souza Britoa, Haroldo Gambini Santosa, "Preprocessing and Cutting Planes with Conflict Graphs", https://arxiv.org/pdf/1909.07780 but maybe random is more robust?
Heuristic: We can abort early if there is no way to reach the threshold here.
This clique is maximal.
We finished exploring node. backtrack.
Definition at line 298 of file cliques.cc.
|
inline |
|
inline |
|
inline |
void operations_research::WeightedBronKerboschBitsetAlgorithm::TakeTransitiveClosureOfImplicationGraph | ( | ) |
This function is quite specific. It interprets node i as the negated literal of node i ^ 1. And all j in graph[i] as literal that are in at most two relation. So i implies all not(j) for all j in graph[i].
The transitive close runs in O(num_nodes ^ 3) in the worst case, but since we process 64 bits at the time, it is okay to run it for graph up to 1k nodes.
We use Floyd-Warshall algorithm.
Loop over all the i => k, we can do that by looking at the not(k) => not(i).
Now i also implies all the literals implied by k.
Definition at line 284 of file cliques.cc.
|
inline |