V
- the graph vertex typeE
- the graph edge typepublic class PivotBronKerboschCliqueFinder<V,E> extends Object
The pivoting follows the rule from the paper
where the authors show that using that rule guarantees that the Bron-Kerbosch algorithm has worst-case running time $O(3^{n/3})$ where $n$ is the number of vertices of the graph, excluding time to write the output, which is worst-case optimal.
The algorithm first computes all maximal cliques and then returns the result to the user. A timeout can be set using the constructor parameters.
BronKerboschCliqueFinder
,
DegeneracyBronKerboschCliqueFinder
Modifier and Type | Field and Description |
---|---|
protected List<Set<V>> |
allMaximalCliques
The result
|
protected Graph<V,E> |
graph
The underlying graph
|
protected int |
maxSize
Size of biggest maximal clique found.
|
protected long |
nanos
Timeout in nanoseconds
|
protected boolean |
timeLimitReached
Whether the last computation terminated due to a time limit.
|
Constructor and Description |
---|
PivotBronKerboschCliqueFinder(Graph<V,E> graph)
Constructs a new clique finder.
|
PivotBronKerboschCliqueFinder(Graph<V,E> graph,
long timeout,
TimeUnit unit)
Constructs a new clique finder.
|
Modifier and Type | Method and Description |
---|---|
protected void |
findCliques(Set<V> P,
Set<V> R,
Set<V> X,
long nanosTimeLimit)
Recursive implementation of the Bron-Kerbosch with pivot.
|
boolean |
isTimeLimitReached()
Check the computation has stopped due to a time limit or due to computing all maximal
cliques.
|
Iterator<Set<V>> |
iterator()
Returns an iterator over all maximal cliques.
|
protected void |
lazyRun()
Lazily execute the enumeration algorithm.
|
Iterator<Set<V>> |
maximumIterator()
Create an iterator which returns only the maximum cliques of a graph.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
protected final Graph<V,E> graph
protected final long nanos
protected boolean timeLimitReached
protected int maxSize
public PivotBronKerboschCliqueFinder(Graph<V,E> graph)
graph
- the input graph; must be simpleprotected void lazyRun()
protected void findCliques(Set<V> P, Set<V> R, Set<V> X, long nanosTimeLimit)
P
- vertices to consider adding to the cliqueR
- a possibly non-maximal cliqueX
- vertices which must be excluded from the cliquenanosTimeLimit
- time limitpublic Iterator<Set<V>> iterator()
MaximalCliqueEnumerationAlgorithm
iterator
in interface Iterable<Set<V>>
iterator
in interface MaximalCliqueEnumerationAlgorithm<V,E>
public Iterator<Set<V>> maximumIterator()
public boolean isTimeLimitReached()
Copyright © 2019. All rights reserved.