zaro

What is Adjacency?

Published in Graph Theory Concepts 3 mins read

Adjacency describes whether two points or nodes are directly connected, while affinity measures the degree of similarity between them.

Understanding the relationship between points or nodes in a dataset or graph is fundamental in various fields, from data science to network analysis. Two key concepts used to represent these relationships are adjacency and affinity. While often represented in a similar matrix format, they convey different types of connections.

What is Adjacency?

Adjacency typically refers to a direct connection between two nodes in a graph or network. In the context of an Adjacency Matrix, this relationship is often represented in a binary way:

  • A value of 1 indicates that the two points or nodes are directly connected (adjacent).
  • A value of 0 indicates that they are not directly connected.

Adjacency is a simple 'yes' or 'no' answer to the question: "Is there a direct link between these two points?"

  • Example: In a social network graph, adjacency might represent whether two people are 'friends'. In a road network, it might represent whether two cities are directly connected by a road.

What is Affinity?

Affinity, on the other hand, measures the similarity or relatedness between two points. As stated in the provided reference:

An Affinity Matrix is like an Adjacency Matrix, except the value for a pair of points expresses how similar those points are to each other.

Instead of a simple binary connection, affinity provides a score that indicates how alike two points are.

  • If pairs of points are very dissimilar then the affinity should be 0.
  • If the points are identical, then the affinity might be 1.

Affinity scores typically range from 0 (completely dissimilar) to 1 (identical or maximally similar), though other ranges or interpretations of the score's scale are possible depending on the specific application and how similarity is calculated.

  • Example: In a recommender system, affinity might measure the similarity between user preferences or item characteristics. In image processing, it might measure the similarity between pixel colors or textures.

Key Differences Summarized

The primary difference lies in what the value represents: a direct link versus a degree of similarity.

Feature Adjacency Affinity
What it Measures Direct connection/link Degree of similarity/relatedness
Typical Value Often binary (0 or 1) Continuous value (e.g., between 0 and 1)
Meaning of 0 No direct connection Completely dissimilar
Meaning of 1 Direct connection exists Identical or maximally similar
Focus Structure of connections Relationship based on attributes

Both adjacency and affinity can be represented using matrix structures, where rows and columns correspond to the points, and the cell at the intersection of a row and column contains the value (either adjacency status or affinity score) for that pair of points.

In summary, while an Adjacency Matrix tells you if two points are connected, an Affinity Matrix tells you how similar they are.