Class MaximalCliques

Inheritance Relationships

Base Type

Class Documentation

class MaximalCliques : public NetworKit::Algorithm

Algorithm for listing all maximal cliques.

The implementation is based on the “hybrid” algorithm described in

Eppstein, D., & Strash, D. (2011). Listing All Maximal Cliques in Large Sparse Real-World Graphs. In P. M. Pardalos & S. Rebennack (Eds.), Experimental Algorithms (pp. 364 - 375). Springer Berlin Heidelberg. Retrieved from http://link.springer.com/chapter/10.1007/978-3-642-20662-7_31

The running time of this algorithm should be in \(O(d^2 \cdot n \cdot 3^{d/3})\) where \(d\) is the degeneracy of the graph, i.e., the maximum core number. The running time in practice depends on the structure of the graph. In particular for complex networks it is usually quite fast, even graphs with millions of edges can usually be processed in less than a minute.

Public Functions

MaximalCliques(const Graph &G, bool maximumOnly = false)

Construct the maximal cliques algorithm with the given graph.

If the maximumOnly argument is set, the algorithm will only store the clique of maximum size. Further, this enables some optimizations to skip smaller cliques more efficiently leading to a reduced running time.

Parameters:
  • G – The graph to list the cliques for.

  • maximumOnly – If only a maximum clique shall be found.

MaximalCliques(const Graph &G, std::function<void(const std::vector<node>&)> callback)

Construct the maximal cliques algorithm with the given graph and a callback.

The callback is called once for each found clique with a reference to the clique. Note that the reference is to an internal object, the callback should not assume that this reference is still valid after it returned.

Parameters:
  • G – The graph to list cliques for

  • callback – The callback to call for each clique.

virtual void run() override

Execute the maximal clique listing algorithm.

const std::vector<std::vector<node>> &getCliques() const

Return all found cliques unless a callback was given.

This method will throw if a callback was given and thus the cliques were not stored. If only the maximum clique was stored, it will return exactly one clique unless the graph is empty.

Returns:

a vector of cliques, each being represented as a vector of nodes.