Distance functions for similarity construction
A similarity graph represents each data point as a vertex and each pairwise similarity as an edge weight.
From distances to connections
Clustering is often introduced as the task of grouping similar data points. A graph-based formulation makes that idea visible: each data point becomes a vertex, and the relationship between two points becomes a weighted edge. The central challenge is to decide how strongly two points should be connected. A distance function measures how far apart two points are, and a similarity construction converts that distance into an edge weight.
The weight should represent similarity rather than distance. In the clustering formulation described by the source, points placed in the same group should have high-weight internal edges, while points placed in different groups should have low-weight edges between them. Thus, the graph stores the pairwise evidence that a clustering method uses.
Data points as weighted vertices
Suppose a collection contains three data points. The graph representation gives each point a vertex. Every pairwise relationship is represented by an edge whose weight records the similarity assigned to that pair. A larger edge weight means that the pair has been assigned a stronger similarity in the graph.
A distance function is one possible starting point for assigning these weights. The source describes using a distance function d together with a parameter σ in a specified exponential expression. That expression uses the distance between two points to define an entry of the similarity matrix W. The important construction idea is that pairwise distances are transformed into pairwise similarity weights before the graph is partitioned.
Reading the similarity matrix
The weighted graph can be recorded as a similarity matrix W. Each entry Wᵢ,ⱼ represents the similarity weight associated with the relationship between data point i and data point j. In this way, the matrix is not a separate idea from the graph: it is a tabular representation of the graph's pairwise edge weights.
A three-point similarity matrix
Use the generated similarity matrix W to identify the pairwise weights and calculate the degree associated with each point.
Choose W: Let W contain the pairwise weights 0.8 for Points 1 and 2, 0.2 for Points 1 and 3, and 0.3 for Points 2 and 3. These values are a generated teaching example.
Read Point 1's row: The row for Point 1 contains the weights 0.8 and 0.2 for its relationships with the other points.
Read Point 2's row: The row for Point 2 contains the weights 0.8 and 0.3 for its relationships with the other points.
Read Point 3's row: The row for Point 3 contains the weights 0.2 and 0.3 for its relationships with the other points.
The matrix records all pairwise similarity weights. The degree calculation uses the sum of the corresponding row of W.
Degrees from row sums
The degree matrix D is a diagonal matrix. Its diagonal entry Dᵢ,ᵢ equals the sum of the corresponding row of W. The degree therefore collects the total similarity weight associated with a data point, according to the weights recorded in W.
Calculating D from W
For the generated pairwise weights 0.8, 0.2, and 0.3, calculate the diagonal entries of the degree matrix.
Point 1: Add the similarities in Point 1's row: 0.8 + 0.2 = 1.0. Therefore D₁,₁ = 1.0.
Point 2: Add the similarities in Point 2's row: 0.8 + 0.3 = 1.1. Therefore D₂,₂ = 1.1.
Point 3: Add the similarities in Point 3's row: 0.2 + 0.3 = 0.5. Therefore D₃,₃ = 0.5.
Place the values on the diagonal: Because D is diagonal, the three calculated values occupy D₁,₁, D₂,₂, and D₃,₃. The off-diagonal positions of D are zero.
For this generated example, the degree matrix has diagonal entries 1.0, 1.1, and 0.5.
Partitioning the graph
Once pairwise similarities have been represented as weighted edges, clustering becomes a graph-partitioning problem. A useful partition places strongly connected points in the same group and keeps weakly connected relationships between groups. This expresses both sides of the clustering objective: high-weight internal edges and low-weight edges that cross from one group to another.
In the generated example, Points 1 and 2 have weight 0.8 between them, while their relationships with Point 3 have weights 0.2 and 0.3. A partition placing Points 1 and 2 together and Point 3 in another group follows the stated objective: the strongest relationship remains internal, and the weaker relationships cross the group boundary.
Subtracting W from D
The unnormalized graph Laplacian is defined as L = D - W. It combines the diagonal degree information in D with the pairwise similarity information in W. The Laplacian is the central mathematical object in this graph-based formulation of clustering.
Building L in the generated example
Use the generated degree values 1.0, 1.1, and 0.5 together with the generated similarity weights to construct the unnormalized graph Laplacian.
Start with D: Place 1.0, 1.1, and 0.5 on the diagonal of D.
Use W: Use the pairwise weights 0.8, 0.2, and 0.3 in the corresponding positions of W.
Subtract: Compute each entry of L by subtracting the corresponding entry of W from the corresponding entry of D.
Interpret the positions: On the diagonal, D contributes the degree and W is subtracted. Off the diagonal, D contributes its diagonal structure while the pairwise W entries are subtracted.
The result is the unnormalized graph Laplacian L = D - W. Its entries combine total connection strength with pairwise similarity structure.
Three matrices, three roles
| Object | What it contains | How it is obtained | Role in the construction |
|---|---|---|---|
| W | Pairwise similarity weights | Weights are defined from pairwise relationships; a distance function and parameter σ can be used in an exponential similarity expression | Represents the weighted graph's relationships |
| D | Diagonal degree values | Each diagonal entry is the sum of the corresponding row of W | Records the total similarity weight associated with each point |
| L | The unnormalized graph Laplacian | L = D - W | Serves as the central mathematical object in the graph-based clustering formulation |
The sequence from pairwise similarities to the unnormalized graph Laplacian.
A reliable way to remember the sequence is: first construct W from pairwise similarity information; then sum each row of W to obtain the diagonal entries of D; finally subtract W from D to obtain L. W describes relationships, D summarizes each point's total relationship weight, and L combines those two views.
Common construction mistakes
Treating W as a distance matrix rather than a similarity matrix.
The graph formulation described here uses entries of W as similarity weights on edges.
Fix:
Interpret Wᵢ,ⱼ as the similarity weight assigned to the relationship between points i and j.Using one W entry as the degree of a point.
The degree matrix is defined from the sum of the corresponding row of W.
Fix:
Add all similarity weights in the relevant row before placing the result on D's diagonal.Putting degree values throughout D.
D is diagonal.
Fix:
Place each degree only in its matching diagonal position.Constructing L by adding D and W.
The unnormalized graph Laplacian is defined by subtraction.
Fix:
Use L = D - W and subtract corresponding entries.Choosing groups based only on isolated point labels.
The graph-partitioning objective concerns high-weight internal edges and low-weight edges between groups.
Fix:
Inspect the weight structure represented by W.
Check your construction
A generated three-point graph has pairwise similarity weights 0.6 between Points 1 and 2, 0.1 between Points 1 and 3, and 0.4 between Points 2 and 3. Explain which pair has the strongest internal connection if Points 1 and 2 are proposed as one group. Then calculate the three diagonal entries of D by summing the corresponding rows of W, and state how L is obtained from D and W.
Hints
- The strongest proposed internal connection is the largest weight between the two points in the proposed group.
- For each degree, add the two pairwise weights appearing in that point's row.
- After constructing D, use the unnormalized definition L = D - W.
- A distance function can provide pairwise information that is converted into similarity weights. Those weights form W, where each data point is a vertex and each pairwise relationship is a weighted edge. Graph partitioning seeks groups with high-weight internal edges and low-weight edges between groups. The degree matrix D is diagonal, with each Dᵢ,ᵢ equal to the sum of row i of W. The unnormalized graph Laplacian is then constructed as L = D - W.
Key Takeaways
- A similarity graph represents data points as vertices and pairwise similarities as weighted edges.
- A distance function and parameter can be used to define similarity weights for W through a specified exponential expression.
- Graph partitioning aims for high-weight connections inside groups and low-weight connections between groups.
- The degree matrix D is diagonal, and each diagonal entry is the sum of the corresponding row of W.
- The unnormalized graph Laplacian combines the two matrices through L = D - W.