documentationfor yFiles for HTML 3.0.0.3

KMeansClustering

Partitions the graph into clusters using k-means clustering.

Inheritance Hierarchy
KMeansClustering

Remarks

The nodes of the graph will be partitioned into k clusters, based on their positions such that their distance to the cluster's mean (centroid) is minimized.

Other Clustering Algorithms

@PRODUCT@ supports a number of other clustering algorithms:

Examples

Calculating the k-means clusters of a graph
// prepare the k-means clustering algorithm
const algorithm = new KMeansClustering()
// run the algorithm
const result = algorithm.run(graph)

// highlight the nodes of the clusters with different styles
for (const node of graph.nodes) {
  const componentId = result.nodeClusterIds.get(node)!
  graph.setStyle(node, clusterStyles.get(componentId)!)
}

Type Details

yFiles module
view-layout-bridge

See Also

If the number of given centroids is smaller than k or if no centroids are given, random initial centroids will be assigned for all clusters.

Constructors

Properties

Methods