Inferensys

Glossary

Product Affinity Graph

A network structure where nodes represent products and edges represent co-purchase or co-view relationships, used to generate substitutable or complementary recommendations.
Overhead shot of a beautifully lit strategy meeting in a modern WeWork hot desk area, designers and executives gathered around a live AI system diagram projected on smart table surface.
RELATIONAL DATA STRUCTURE

What is Product Affinity Graph?

A Product Affinity Graph is a network structure where nodes represent products and edges represent co-purchase or co-view relationships, used to generate substitutable or complementary recommendations.

A Product Affinity Graph is a relational data structure that models products as interconnected nodes, with weighted edges quantifying the strength of their relationship based on observed customer behavior such as co-purchases, co-views, or sequential cart additions. Unlike simple collaborative filtering, this graph explicitly encodes directional and typed relationships—such as complement or substitute—enabling a merchandising engine to traverse the network and retrieve contextually relevant items for dynamic assortment optimization.

In a real-time retail environment, the graph powers inventory-aware substitution logic by identifying the strongest available alternative when a primary item stocks out, preventing broken customer journeys. By analyzing local purchasing patterns, a localized affinity scoring mechanism can re-weight graph edges for specific geographic clusters, ensuring that a substitute recommendation in one region does not cannibalize a complement in another.

RELATIONAL STRUCTURES

Key Characteristics of Product Affinity Graphs

Product Affinity Graphs are network structures where nodes represent products and edges represent co-purchase or co-view relationships, used to generate substitutable or complementary recommendations.

01

Graph Topology & Edge Weighting

The graph is a weighted, directed network where edge strength quantifies the affinity between two products. Weights are typically derived from conditional probability—the likelihood of purchasing product B given product A is in the cart—or from cosine similarity between product embedding vectors. This structure enables the system to distinguish between strong complements (e.g., a phone and its specific case) and weak associations (e.g., a phone and a generic screen cleaner).

02

Complement vs. Substitute Logic

Edges are categorized by relationship type to power distinct merchandising strategies. A complementary edge connects items bought together (e.g., a camera and a memory card), driving cross-sell recommendations. A substitutable edge connects items viewed or bought instead of each other (e.g., two brands of the same cereal), enabling intelligent backfill when a product is out of stock. This classification is often determined by analyzing post-purchase return rates or session co-browsing patterns.

03

Real-Time Inventory Awareness

Modern affinity graphs integrate with inventory telemetry to prevent recommending unavailable items. Each node carries a dynamic stock_status attribute. During graph traversal for recommendation generation, nodes with a stockout_probability above a threshold are pruned from the candidate set. This ensures the system only surfaces availability-weighted relevance, directly linking the graph's mathematical structure to operational reality.

04

Localized Affinity Scoring

Global affinity graphs often fail to capture regional taste variations. Localized Affinity Scoring creates geo-specific graph layers by filtering co-purchase data through a geospatial demand cluster. An edge between craft beer A and craft beer B might be strong in one city but nonexistent in another. This allows the same recommendation engine to serve a micro-merchandising zone with culturally relevant suggestions without manual curation.

05

Cold Start Mitigation via Content-Based Edges

New products with no transactional history lack collaborative edges. To solve this cold start problem, the graph is initialized with content-based edges derived from product attribute similarity (e.g., same brand, category, color, or material). These edges are initially weak but provide a starting point for exploration. As interaction data accumulates, a contextual assortment bandit can shift traffic from content-based to behavior-based edges, dynamically re-weighting the graph.

06

Demand Transference for Substitution

When a primary product is out of stock, the affinity graph drives demand transference modeling. The system traverses the outbound substitutable edges of the unavailable node, selecting the connected product with the highest edge weight that is currently in stock. This predicts which alternative the customer is most likely to accept, minimizing lost revenue. The success of the substitution is fed back into the graph to reinforce or decay the edge weight.

PRODUCT AFFINITY GRAPH

Frequently Asked Questions

Clear, technical answers to the most common questions about product affinity graphs, their mechanisms, and their role in dynamic retail hyper-personalization.

A product affinity graph is a network data structure where nodes represent individual products and edges represent the strength and type of relationship between them—such as co-purchase frequency, co-view similarity, or substitutability. It works by ingesting historical transaction and behavioral data, then applying algorithms like collaborative filtering, market basket analysis, or graph neural networks to calculate edge weights. These weights quantify the probability that a customer who interacts with product A will also engage with product B. The resulting graph enables real-time retrieval of related items for recommendation carousels, search ranking boosts, and dynamic assortment logic. Unlike simple item-to-item similarity matrices, a graph structure allows for multi-hop reasoning—traversing from a seed product through intermediate nodes to discover non-obvious, high-affinity recommendations that a direct pairwise comparison would miss.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.