Interface MaximalCliquesEnumerator
-
- All Known Implementing Classes:
MaximalCliquesEnumeratorAbstract
,MaximalCliquesEnumeratorBronKerbosch
,MaximalCliquesEnumeratorBronKerboschPivot
public interface MaximalCliquesEnumerator
Algorithm for enumerating over all maximal cliques in a graph.A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent (connected by an edge). A maximal clique is a clique that cannot be extended by including one more adjacent vertex.
There may be exponentially many maximal cliques in a graph, therefore all implementations of this interface use some heuristic to speed up the process but run in exponential time in the worst case. The algorithm returns an iterator over the cliques, so that the caller can iterate over them without storing them all in memory. Avoid using this algorithm on very large graphs.
Use
newInstance()
to get a default implementation of this interface.Graph<String, Integer> g = ...; MaximalCliquesEnumerator maxCliquesAlgo = MaximalCliquesEnumerator.newInstance(); for (Iterator<Set<String>> it = maxCliquesAlgo.maximalCliquesIter(g); it.hasNext();) { Set<String> clique = it.next(); System.out.println("Maximal clique in the graph:"); for (String v : clique) System.out.println("\t" + v); }
- Author:
- Barak Ugav
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <V,E>
Iterator<Set<V>>maximalCliquesIter(Graph<V,E> g)
Iterate over all maximal cliques in a graph.static MaximalCliquesEnumerator
newInstance()
Create a new maximal cliques algorithm object.
-
-
-
Method Detail
-
maximalCliquesIter
<V,E> Iterator<Set<V>> maximalCliquesIter(Graph<V,E> g)
Iterate over all maximal cliques in a graph.The input graph should not be changed during the iteration.
If
g
isIntGraph
, the returned iterator will be iterate overIntSet
.- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- a graph- Returns:
- an iterator that iterates over all maximal cliques in the graph
-
newInstance
static MaximalCliquesEnumerator newInstance()
Create a new maximal cliques algorithm object.This is the recommended way to instantiate a new
MaximalCliquesEnumerator
object.- Returns:
- a default implementation of
MaximalCliquesEnumerator
-
-