all_cliques#
- graph_tool.structure.all_cliques(g, min_size=1, max_size=None)[git][source]#
Return an iterator over all cliques of a graph, maximal or not.
- Parameters:
- g
Graph Graph to be used. Edge directions, self-loops, and parallel edges are ignored.
- min_size
int(optional, default:1) Smallest size of the cliques returned.
- max_size
int(optional, default:None) If given, largest size of the cliques returned.
- g
- Returns:
- cliquesiterator over
numpy.ndarray The vertices of every clique.
- cliquesiterator over
See also
maximal_cliquesMaximal cliques only
largest_cliquesCliques of maximum size
graph_tool.clustering.motifsCounts of connected subgraphs
Notes
Unlike
maximal_cliques(), which returns only the maximal cliques, every complete subgraph is returned once. The vertices are ordered by degeneracy (smallest-last), and each clique is generated from its first vertex in this order by adding later common neighbors, so that the time is \(O(d)\) per clique vertex, where \(d\) is the degeneracy. The number of cliques can grow exponentially with \(d\).Examples
>>> g = gt.complete_graph(4) >>> print(len(list(gt.all_cliques(g)))) 15 >>> print(sorted(len(c) for c in gt.all_cliques(g, min_size=3))) [3, 3, 3, 3, 4]