Maximal cliques

Finds every group of vertices that are all adjacent to each other and can't take one more vertex.

Time complexity O(3^(V/3)), gograph function partition.MaximalCliques.

Friend groups

Twelve friends in three circles: a climbing group, a book club and a band. Each edge joins two friends. Eli climbs and reads, and Hana reads and plays in the band, so each of them links two circles.

An undirected graph with 12 vertices and 21 edges.

Which groups of friends all know each other, where no one else knows everyone in the group?

Use it in Go

for _, clique := range partition.MaximalCliques(g) {
	var names []string
	for _, v := range clique {
		names = append(names, v.Label())
	}
	fmt.Println(strings.Join(names, ", "))
}

Example graphs

More in Partitioning

  • Girvan-Newman: Splits an undirected graph into k communities by removing, one at a time, the edge that the most shortest paths cross.
  • Randomized k-cut: Splits an undirected graph into k groups by merging the ends of random edges until k groups are left, and cuts the edges between them.

All algorithms