Skip to content
C

Problem 4: Manually Calculate Distance Between Clusters

Easypython

Problem Description

Write a Python program that manually calculates the single-linkage distance (minimum pairwise distance) between two given clusters of points, without using any built-in clustering function.

Input

Two lists of 2D points, representing two separate clusters.

Output

The minimum distance between any point in the first cluster and any point in the second.

Constraints

  • Each cluster has at least 2 points.

Example Input

text
cluster_a=[[1,1],[2,2]], cluster_b=[[8,8],[9,9]]

Example Output

text
Minimum distance (single linkage): 8.49

Concepts Covered

Manual distance calculation, nested loops, min().

Input (stdin)

Output

Run your code to see output here...