documentationfor yFiles for HTML 2.6

CliqueSubstructures

Detects SubstructureItemss that represent the (undirected) cliques in the specified graph.

Inheritance Hierarchy
CliqueSubstructures

Remarks

A clique is a subset of nodes of the same type (nodeTypes) that are all adjacent (i.e., connected) to each other.

Cliques with less than minimumSize nodes are ignored.

Note that finding a maximum clique is NP-hard. Hence, we only use a simple heuristic approach that doesn't guarantee to find all/the largest clique. It only identifies cliques that have at least one node with at most one non-clique neighbor. Furthermore, a node can only be contained in a single clique, i.e., the returned cliques are non-overlapping.

Examples

Finding the cliques in a graph
// prepare the clique detection algorithm
const algorithm = new CliqueSubstructures()
// run the algorithm
const result = algorithm.run(graph)

// highlight the cliques
for (const clique of result.cliques) {
  for (const node of clique.nodes) {
    graph.setStyle(node, highlightNodeStyle)
  }
  for (const edge of clique.edges) {
    graph.setStyle(edge, highlightEdgeStyle)
  }
}
Finding only the cliques in a graph whose nodes are of the same type
// prepare the clique detection algorithm
const algorithm = new CliqueSubstructures({
  // only nodes with the same tags can be a clique
  nodeTypes: (node) => node.tag
})
// run the algorithm
const result = algorithm.run(graph)

// highlight the cliques
for (const clique of result.cliques) {
  for (const node of clique.nodes) {
    graph.setStyle(node, highlightNodeStyle)
  }
  for (const edge of clique.edges) {
    graph.setStyle(edge, highlightEdgeStyle)
  }
}// prepare the clique detection algorithm
const algorithm = new CliqueSubstructures({
  // only nodes with the same tags can be a clique
  nodeTypes: (node: INode): any => node.tag
})
// run the algorithm
const result = algorithm.run(graph)

// highlight the cliques
for (const clique of result.cliques) {
  for (const node of clique.nodes) {
    graph.setStyle(node, highlightNodeStyle)
  }
  for (const edge of clique.edges) {
    graph.setStyle(edge, highlightEdgeStyle)
  }
}

Type Details

yfiles module
view-layout-bridge
yfiles-umd modules
view-layout-bridge
Legacy UMD name
yfiles.analysis.CliqueSubstructures

See Also

A clique only consists of elements with the same nodeTypes, i.e., nodes associated with equal objects. If no nodeTypes is specified, all node are considered to be of the same type.

Constructors

Properties

Methods