Wolfram Research

Function Repository Resource:

SymbolDependencyGraph (1.0.0) current version: 1.1.0 »

Source Notebook

Create a graph of symbol dependencies

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["SymbolDependencyGraph"][symbol]

displays a Graph corresponding to the symbol dependencies of symbol.

Details and Options

An edge ab will appear in the graph if the symbol b appears in the definition of symbol a.
SymbolDependencyGraph takes the same options as Graph.

Examples

Basic Examples (1) 

Use the function:

In[1]:=
a := Hold[b, c];
b := 1;
c := d;
d := Hold[a, b, e];
e := 2;
ResourceFunction["SymbolDependencyGraph"][a, VertexLabels -> "Name", ImageSize -> 150]
Out[6]=

Scope (3) 

Retrieve the ResourceFunction:

In[7]:=
ResourceFunction["SymbolDependencyGraph"]
Out[7]=

Retrieve the ResourceObject:

In[8]:=
ResourceObject["SymbolDependencyGraph"]
Out[8]=

See how a function relies on other functions:

In[9]:=
ResourceFunction["SymbolDependencyGraph", ResourceVersion->"1.0.0"][GeneralUtilities`PrintDefinitions, VertexLabels -> Placed["Name", Tooltip]]
Out[9]=

Applications (1) 

See how symbols in a context are related:

In[10]:=
symbols = ToExpression[Names["GeneralUtilities`*"], InputForm, HoldComplete];
In[11]:=
g = ResourceFunction["SymbolDependencyGraph"][symbols, VertexLabels -> Placed["Name", Tooltip]];
In[12]:=
VertexDelete[g, "symbols"]
Out[12]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.1.0 – 13 March 2023
  • 1.0.1 – 27 January 2023
  • 1.0.0 – 15 August 2018

License Information