UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • Running Algorithms
    • Degree Centrality
    • Closeness Centrality
    • Harmonic Centrality
    • Eccentricity Centrality
    • Betweenness Centrality
    • Bridges
    • Articulation Points
    • Eigenvector Centrality
    • Katz Centrality
    • CELF
    • PageRank
    • ArticleRank
    • TextRank
    • HITS
    • SybilRank
    • Jaccard Similarity
    • Overlap Similarity
    • Cosine Similarity
    • Pearson Correlation Coefficient
    • Euclidean Distance
    • KNN
    • Vector Similarity
    • Bipartite Graph
    • HyperANF
    • Weakly Connected Components (WCC)
    • Strongly Connected Components (SCC)
    • k-Edge Connected Components
    • Local Clustering Coefficient
    • Triangle Count
    • Clique Count
    • k-Core
    • k-Truss
    • p-Cohesion
    • Induced Subgraph
    • Topological Sort
    • Breadth-First Search (BFS)
    • Depth-First Search (DFS)
    • Dijkstra's Shortest Path
    • A* Shortest Path
    • Yen's K-Shortest Paths
    • Shortest Path (BFS)
    • Delta-Stepping SSSP
    • Shortest Path Faster Algorithm (SPFA)
    • All-Pairs Shortest Path (APSP)
    • Minimum Spanning Tree (MST)
    • K-Spanning Tree
    • Steiner Tree
    • Prize-Collecting Steiner Tree (PCST)
    • Minimum Cost Flow
    • Maximum Flow
    • K-Hop Fast
    • Longest Path (DAG)
    • Random Walk
    • Adamic-Adar Index
    • Common Neighbors
    • Preferential Attachment
    • Resource Allocation
    • Total Neighbors
    • Same Community
    • Louvain
    • Leiden
    • Modularity Optimization
    • Label Propagation
    • HANP
    • SLPA
    • k-Means
    • HDBSCAN
    • K-1 Coloring
    • Modularity
    • Conductance
    • Max k-Cut
      • Node2Vec
      • Struc2Vec
      • LINE
      • Fast Random Projection
      • Summary of Graph Embedding
      • Gradient Descent
      • Backpropagation
      • Skip-gram
      • Skip-gram Optimization
  1. Docs
  2. /
  3. Graph Algorithms
  4. /
  5. Graph Structure

Clique Count

Overview

The Clique Count algorithm finds all maximal cliques in a graph using the Bron-Kerbosch algorithm, and reports per-node clique participation. A clique is a subset of nodes where every pair is directly connected. A maximal clique is a clique that cannot be extended by adding any adjacent node.

Concepts

Clique

A clique is a complete subgraph — a set of nodes where every pair is connected by an edge. The size of a clique is the number of nodes it contains:

  • A 2-clique is a single edge between two nodes.
  • A 3-clique (triangle) is three mutually connected nodes.
  • A k-clique is a set of k nodes where all k*(k-1)/2 possible edges exist.

For example, in the following graph, {A, B, C} form a 3-clique and {B, C, D} form another 3-clique. Together {A, B, C, D} do not form a 4-clique because there is no edge between A and D.

Maximal Clique

A maximal clique is a clique that cannot grow any larger — there is no node outside the clique that is connected to every node inside it.

In the graph above:

  • {A, B, C} is a maximal clique
  • {B, C, D} is a maximal clique
  • {B, C} is a clique but not maximal
  • {D, E} is a maximal clique because E is only connected to D

Considerations

  • The algorithm treats all edges as undirected.
  • Complexity is exponential in clique size — practical for cliques up to size 3-5 on large graphs.
  • Self-loops are ignored.

Example Graph

GQL
INSERT (A:default {_id: "A"}), (B:default {_id: "B"}),
       (C:default {_id: "C"}), (D:default {_id: "D"}),
       (E:default {_id: "E"}), (F:default {_id: "F"}),
       (G:default {_id: "G"}),
       (A)-[:default]->(B), (A)-[:default]->(C),
       (A)-[:default]->(D), (B)-[:default]->(C),
       (B)-[:default]->(D), (C)-[:default]->(D),
       (D)-[:default]->(E), (E)-[:default]->(F),
       (E)-[:default]->(G), (F)-[:default]->(G)

Parameters

NameTypeDefaultDescription
maxCliqueSizeINT0Maximum clique size to find (0 = no limit).

Run Mode

Returns:

ColumnTypeDescription
nodeIdSTRINGNode identifier (_id)
cliqueCountINTNumber of maximal cliques containing this node
maxCliqueSizeINTSize of the largest clique containing this node
GQL
CALL algo.cliquecount() YIELD nodeId, cliqueCount, maxCliqueSize

Result:

nodeIdcliqueCountmaxCliqueSize
E23
D24
G13
F13
A14
C14
B14

Stream Mode

Returns the same columns as run mode, streamed for memory efficiency.

GQL
CALL algo.cliquecount.stream({
    maxCliqueSize: 3
}) YIELD nodeId, cliqueCount, maxCliqueSize
RETURN nodeId, cliqueCount, maxCliqueSize

Result:

nodeIdcliqueCountmaxCliqueSize
E23
D12
G13
F13
A00
C00
B00

Stats Mode

Returns:

ColumnTypeDescription
nodeCountINTTotal number of nodes
totalCliquesINTTotal number of maximal cliques found
maxCliqueSizeINTSize of the largest clique
GQL
CALL algo.cliquecount.stats() YIELD nodeCount, totalCliques, maxCliqueSize

Result:

nodeCounttotalCliquesmaxCliqueSize
734