We explore how graph-theoretic concepts such as connected components and vertex Jaccard similarity can be used to identify missing links and improve recommendation systems. By transforming a recommendation system into a recommendation network, where nodes represent items and edges represent recommendations, we analyze the network structure to uncover potential missing links. The connected components reveal disconnected regions of the network, while the vertex Jaccard similarity identifies items with similar neighborhoods that may benefit from additional links. Together, these methods provide a structured approach for discovering gaps in recommendation systems and generating new recommendations, ultimately improving the user experience.

Introduction

Recommendation systems play a critical role in various real-world applications by suggesting products to buy, music to listen to, or content to consume. They are essential in domains such as e-commerce, media streaming, and social media platforms. In this post, we explore a complementary graph-theoretic perspective that reveals the structural relationships within a recommendation system. As a case study, we analyze the See Also network in the Wolfram Language documentation. By modeling the documentation recommendations as a graph, we show how graph-theoretic techniques can identify missing recommendations, improve network connectivity, and suggest meaningful additions to the existing recommendation structure.

Graphs

Graphs are structures composed of vertices (which represent entities) and edges (which represent relationships between those entities). They provide a natural way to represent, visualize, and analyze how entities are interconnected. Graphs can be classified as either undirected or directed. In an undirected graph, edges have no direction, representing bidirectional relationships between vertices. In contrast, directed graphs contain edges with a specific direction, representing one-way relationships from one vertex to another.
For example, in this directed graph with vertices {1,2,3,4} and edges {12,13,14,24,34}, vertex 1 has outgoing connections to vertices 2, 3, and 4, while vertices 1, 2, and 3 have outgoing connections to vertex 4.
Out[]=

Recommendation Graph

The idea behind using graph theory to improve the recommendation systems is to represent the recommendation system as a directed graph, where vertices represent items and directed edges represent recommendations from one item to another. In this representation, an edge from item A to item B indicates that A recommends B. As our recommendation system, we will use the “See Also” recommendation system from the Wolfram Language documentation. This section provides recommendations for related functions, helping users discover additional relevant content and aims to help the user to navigate the documentation more effectively. It appears near the bottom of each documentation page:
Extracting the pages recommended by each documentation page is straightforward in the Wolfram Language. As an example, consider the list of symbols in the See Also section for DirectedEdge:
In[]:=
EntityValue[Entity["WolframLanguageSymbol","DirectedEdge"],"RelatedSymbols"]
Out[]=

UndirectedEdge
,
Graph
,
EdgeList
,
EdgeCount
,
Rule
,
EdgeTaggedGraph
,
IndexEdgeTaggedGraph
,
EdgeTags

We can then represent these recommendations as a directed graph, where each symbol acts as a vertex, and an edge connects a symbol to all every symbols listed in its “See Also” section:
In[]:=
buildSymbolGraph[symbol_] := Module[{relatedSymbols},​​ relatedSymbols = EntityValue[Entity["WolframLanguageSymbol", symbol], "RelatedSymbols"];​​ If[ListQ[relatedSymbols], DirectedEdge[symbol, CommonName[#]] & /@ relatedSymbols​​ , DirectedEdge[symbol, symbol]]]
Using DirectedEdge as an example once again, we have:
In[]:=
buildSymbolGraph["DirectedEdge"]
Out[]=
{DirectedEdgeUndirectedEdge,DirectedEdgeGraph,DirectedEdgeEdgeList,DirectedEdgeEdgeCount,DirectedEdgeRule,DirectedEdgeEdgeTaggedGraph,DirectedEdgeIndexEdgeTaggedGraph,DirectedEdgeEdgeTags}
In[]:=
Graph[buildSymbolGraph["DirectedEdge"],VertexLabels->Automatic]
Out[]=
With this, generating the complete recommendation network simply requires identifying all symbols in the Wolfram Language:
In[]:=
symbolsList = CommonName[EntityClass["WolframLanguageSymbol", "VersionIntroduced" -> Between[{1, 16}]] // EntityList];
And construct the full directed graph based on the recommendations given for each symbol:
In[]:=
recommendationGraph=DeleteDuplicates[Flatten[buildSymbolGraph[#]&/@symbolsList]];
This allows us to visualize how functions are interconnected within the documentation:
In[]:=
GraphPlot[recommendationGraph]
Out[]=
This visualization can already provide insights into the structure of the recommendation system, and help us identify some missing links. In particular, we can observe that we have groups of symbols that are disconnected from the largest part of the network. tIn graph theory, these groups are known as connected components. By identifying these disconnected components, we can detect symbols that may benefit from additional recommendations linking them to the largest connected component, which is what we will do in the next section.

Connected components

A graph is connected if there is a path between every pair of vertices. In other words, any vertex can be reached from any other vertex by following a sequence of edges. Conversely, a disconnected graph contains groups of vertices that are isolated from one another, meaning that some vertices cannot be reached from others.
Each connected group of vertices is called a connected component. A connected component is a maximal connected subgraph in which every pair of vertices is connected by a path. In many real-world networks, one component contains most of the vertices and is known as the giant component.

Connectivity in Directed Graphs

In the directed case, the concept of connectivity becomes more complicated because we need to consider the link directions when determining whether one node can be reached from another. In this scenario, connectivity is classified into three distinct categories: strongly connected, weakly connected, and semi-connected. These categories are determined by the path’s nature and the level of strictness used to define the existence of a path between vertices.
◼
  • A graph is considered strongly connected if, for every pair of vertices, there is a directed path from each vertex to the other, strictly following the direction of the edges. Also, there must be a bidirectional path for every pair of vertices A and B. This means that there must exist a directed path from A to B and a directed path from B to A.
  • ◼
  • A semi-connected graph is one in which, for any pair of vertices A and B, there is a directed path from A to B or from B to A (or both). This type of connectivity is often described as one-sided, meaning that traversal between vertices is possible in at least one direction.
  • ◼
  • A directed graph is weakly connected if it becomes connected when you ignore the direction of edges and treat the graph as if it was undirected. This means that there is a path between every pair of vertices in the underlying undirected graph. As a result, not all the nodes within a weakly connected component can be reached following the directed paths.
  • Components in directed networks

    Directed graphs can also be divided into three types of components: strongly connected components, semi-connected components, and weakly connected components:
    ◼
  • Strongly connected components: A strongly connected component is a subset of vertices where every vertex can be reached from any other vertex by strictly following the directed edges. In this component, there is a path in both directions between any pair of vertices.
  • ◼
  • Semi-connected components: A semi-connected component is a subset of vertices where you can reach a vertex from any other vertex in at least one direction by following the directed edges. However, there is no requirement for a return path in the opposite direction.
  • ◼
  • Weakly connected components: A weakly connected component is a subset of vertices where every vertex can be reached from any other vertex if the direction of edges is ignored. Essentially, if you consider the graph as undirected, all vertices in a weakly connected component are reachable from one another.
  • In our recommendation network, we begin by identifying the weakly connected components. This allows us to locate the giant weakly connected component and identify symbols that lie outside it. These disconnected groups represent potential blind spots in the recommendation system, where missing recommendations may prevent users from discovering relevant content.
    Out[]=
    We can identify weakly connected components that are not part of the giant component:
    In[]:=
    WeaklyConnectedComponents[recommendationGraph][[2;;]]
    Out[]=
    {{NotLessGreater,LessGreater,LessEqualGreater,GreaterEqualLess,GreaterLess,NotGreaterLess},{DistributionParameterAssumptions,PointProcessParameterAssumptions,ProcessParameterAssumptions,DistributionParameterQ,PointProcessParameterQ,ProcessParameterQ},{MagneticPotentialCondition,MagneticPDEComponent,MagneticSymmetryValue,MagneticFluxDensityValue,MagnetostaticPDEComponent},{SpanSymmetric,SpanMaxSize,SpanMinSize,SpanLineThickness,SpanAdjustments},{RegionMaxCurvature,RegionMinCurvature,RegionMeanCurvature,RegionGaussianCurvature},{NotGreaterGreater,GreaterGreater,NestedGreaterGreater,NotNestedGreaterGreater},{Infix,Prefix,Postfix,PrecedenceForm},{CounterStyleMenuListing,CounterFunction,CounterAssignments,CounterIncrements},{DefaultStyleDefinitions,DefaultNotebook,StyleSheetPath,NotebookPath},{DefineInputStreamMethod,$InputStreamMethods,RemoveInputStreamMethod},{DefaultNewCellStyle,DefaultNewInlineCellStyle,DefaultDuplicateCellStyle},{DefineOutputStreamMethod,$OutputStreamMethods,RemoveOutputStreamMethod},{AddOnHelpPath,SystemHelpPath,HelpBrowserSettings},{PreferencesPath,ConfigurationPath},{DisplayEndPacket,DisplayPacket},{OutputNamePacket,InputNamePacket},{DifferentialD,CapitalDifferentialD},{PasteBoxFormInlineCells,AllowInlineCells},{PrintingStartingPageNumber,PrintingPageRange},{MultiedgeStyle,SelfLoopStyle},{AutoOpenPalettes,PalettePath},{SystemsModelDelete,SystemsModelExtract},{PlusMinus,MinusPlus},{PageFooterLines,PageHeaderLines},{ContinuousTimeModelQ,DiscreteTimeModelQ},{TabSpacings,TabFilling},{NotebookBrowseDirectory},{ScaleOrigin},{GaugeLabels},{PrivateEvaluationOptions},{OptionInspectorSettings},{StyleMenuListing},{EvaluatorNames},{NotebookConvertSettings},{PrintAction},{MultilaunchWarning},{GaugeFrameSize},{EvaluationCompletionAction},{TraditionalFunctionNotation},{PrintingCopies},{ScaleDivisions},{BoxFormFormatTypes},{RulerUnits},{EditCellTagsSettings},{IncludeFileExtension},{SpanCharacterRounding},{ClosingAutoSave},{ZeroWidthTimes},{NotebooksMenu},{ShowClosedCellArea},{ColorSelectorSettings},{FileNameDialogSettings},{ShowShortBoxForm}}
    This allows us to focus on reconnecting isolated entities to the main graph. For example, the symbols “NotLessGreater” and “LessGreater” can be linked to the symbol “Greater,” which is part of the giant component. Adding such edges incorporates these previously disconnected nodes into the giant weakly connected component. Introducing these links improves the visibility and accessibility of items in smaller components, providing users with a richer and more complete set of recommendations. And, for this recommendation system, we propose the following additional links (ignoring the Symbols that have not been fully integrated into the long-term Wolfram Language, and are subject to change, such as ShowShortBoxForm):
    This produces the updated graph:

    Similarity

    A key concept in graph analysis is the notion of similarity between vertices. Two vertices in a network are considered similar if they share a significant number of common neighbors. For instance, consider two history students at the same university; they are likely to have various shared connections, including mutual friends, fellow students in their program, and history professors. This overlap in their social circles and academic environments makes them similar.

    Jaccard Similarity

    In a recommendation network, Jaccard similarity can effectively help us identify items that should be linked but currently are not. For example, two books on related topics may recommend many of the same titles; however, if they lack a direct connection, Jaccard similarity can help us flag them as potential candidates for linkage. High Jaccard similarity can therefore be used as a signal for missing recommendations.
    To identify the Jaccard similarity between vertex 1 and vertex 2, we can use the following command:
    By applying a threshold on Jaccard similarity, we can propose new edges in the network:

    Examples

    We now apply this idea to the Wolfram Language documentation network. By analyzing local neighborhoods of symbols, we can identify potential missing recommendations. For example, by examining a subgraph derived from the seed symbol “Graph”:
    We can extract the suggested “see also” recommendations within this specific subgraph:
    Similarly, by analyzing the subgraph associated with the seed symbol “D”, we can extract the suggested recommendations:
    For some symbols, the recommendation structure can be already complete, and no additional “see also” are suggested:
    With this we can generate all the suggestion for additional “See Also”:
    And the new recommendation graph will be:
    With these recommendations added, we can analyze an important structural property of the network known as the graph reciprocity. The reciprocity of a directed graph is defined as the fraction of edges that are bidirectional, meaning that if there is an edge from node u to node v, there is also an edge from v to u. Telling us how often relationships in the network are mutual. In recommendation systems, higher reciprocity can indicate stronger consistency between related items. We can therefore compare the reciprocity of the network before and after adding the proposed links. This allows us to quantify how the additional recommendations improve structural balance and mutual connectivity within the graph.
    The fact that the reciprocity changes only from 0.58 to 0.60 indicates that the added recommendations are not simply creating reciprocal links between existing recommendations. Instead, it can be seen as a sign that the new links also introduce additional connections throughout the network.

    Conclusion

    Graph theory metrics like connectivity and Jaccard similarity offer a practical way to spot missing links and enhance recommendation networks. This technique is versatile and can be used in various recommendation systems to improve content discovery and user experience.

    CITE THIS NOTEBOOK

    Improving recommendation systems using graph theory​
    by Alejandra Ortiz Duran​
    Wolfram Community, STAFF PICKS, July 3, 2026
    https://community.wolfram.com/groups/-/m/t/3744064