Package org.graph4j.clique
Class MaximalCliqueFinder
java.lang.Object
org.graph4j.SimpleGraphAlgorithm
org.graph4j.clique.MaximalCliqueFinder
Computes a maximal clique. This class contains both a simple heuristic for
determining a single maximal clique and a method that attempts to find the
maximum clique by enumerating all of them using Bron-Kerbosch algorithm.
A maximal clique is a clique that cannot be extended by including
one more adjacent vertex.
A maximum clique is a clique of largest size in the graph.
Determining a maximum clique is a NP-hard problem.
- Author:
- Cristian Frăsinaru
- See Also:
-
Field Summary
Fields inherited from class org.graph4j.SimpleGraphAlgorithm
graph -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindMaximumClique(long timeLimit) This method iterates over all maximal cliques of the graph, in order to find the maximum one.If it cannot finish in the alloted time, it returnsnull.Returns a maximal clique.getMaximalClique(int startVertex) Creates a maximal clique starting with the given vertex.Methods inherited from class org.graph4j.SimpleGraphAlgorithm
getGraph
-
Constructor Details
-
MaximalCliqueFinder
-
-
Method Details
-
getMaximalClique
Returns a maximal clique. The algorithm tries to create a maximal clique starting with vertices of higher degree. For each vertex, it invokes the methodgetMaximalClique(int)in order to construct a maximal clique including that vertex. At the end, it returns the largest clique found.- Returns:
- a maximal clique.
-
getMaximalClique
Creates a maximal clique starting with the given vertex. The additional vertices of the clique are added in descending order of their degree in the graph.- Parameters:
startVertex- the first vertex added to the maximal clique.- Returns:
- a maximal clique.
-
findMaximumClique
This method iterates over all maximal cliques of the graph, in order to find the maximum one.If it cannot finish in the alloted time, it returnsnull.- Parameters:
timeLimit- a time limit in milliseconds (0 for no time limit).- Returns:
- the maximum clique of the graph or
nullif it cannot be found in the alloted time.
-