Get started with prunecluster CDN

MIT licensed

Library: PruneCluster. Clusters & reduces large datasets with HDBSCAN.

Tags:
  • map
  • clustering
  • leaflet
  • marker
  • realtime

Stable version

Copied!

How to start using prunecluster CDN


// Include the PruneCluster library from the CDN
const PruneCluster = (() => {
  const script = document.createElement('script');
  script.src = 'https://cdn.cdnhub.io/prunecluster/2.1.0/PruneCluster.js';
  document.head.appendChild(script);

  return new Promise(resolve => {
    script.onload = () => {
      resolve(PruneCluster);
    };
  });
})();

// Sample dataset
const dataset = [
  [1, 2, 3],
  [1, 2, 4],
  [1, 3, 3],
  [2, 2, 3],
  [2, 3, 3],
  [3, 3, 3],
];

// Perform clustering and pruning
async function runExample() {
  try {
    const clusteringResult = await PruneCluster.cluster(dataset, {
      maxClusterSize: 2,
      minPointsPerCluster: 2,
    });

    console.log('Clustering result:', clusteringResult);

    const prunedResult = await PruneCluster.prune(clusteringResult, {
      maxDistance: 2,
    });

    console.log('Pruned clustering result:', prunedResult);
  } catch (error) {
    console.error('Error:', error);
  }
}

// Run the example
runExample();
Copied!
Copied!
Copied!
Copied!
Copied!

All versions