Function Repository Resource:

# NestGraphTagged

Create a graph by successively applying a function and differently tagging edges corresponding to different outputs

Contributed by: Nikolay Murzin and Ed Pegg Jr.
 ResourceFunction["NestGraphTagged"][f,expr,n] gives the tagged graph obtained by starting with expr and applying f successively n times.

## Details and Options

The expr can be any expression.
ResourceFunction["NestGraphTagged"][f,expr] is equivalent to ResourceFunction["NestGraphTagged"][f,expr,1].
ResourceFunction["NestGraphTagged"][f,expr] gives a graph with tagged edges , where f[expr] evaluates to {expr1,,exprk}.
If a function f[expr] returns a list values of the form tagexpr or an association <|tag1expr1,tag2expr2,|>, then those tags are used instead.
ResourceFunction["NestGraphTagged"] takes the same options as Graph with the following additions:
 "StateLabeling" False whether to render states as boxes "RuleStyling" Automatic list of styles for edges/rules "FormattingFunction" Automatic how to format a state "PostProcessGraph" Identity post-process graph
Any None on the right-hand side of the rule is dropped from the graph.
One can use integers in place of tagged directed edges to specify EdgeLabels.
PlotLegends can be used to get a legend for different edge rules.

## Examples

### Basic Examples (5)

Make a nested graph with edge coloring:

 In[1]:=
 Out[1]=

Use a pure function:

 In[2]:=
 Out[2]=

Use a list of initial expressions:

 In[3]:=
 Out[4]=

Add a legend to explain colors:

 In[5]:=
 Out[5]=

Label the vertex states in a nested graph:

 In[6]:=
 Out[6]=

### Scope (6)

Edge colorings can be overridden:

 In[7]:=
 Out[7]=

Add labels to edges with EdgeLabels and a pattern:

 In[8]:=
 Out[8]=

Add edge labels using output index:

 In[9]:=
 Out[9]=

 In[10]:=
 Out[10]=

Make custom edge tags by returning a list of rules (tags will be pairs of the form {key, index}):

 In[11]:=
 Out[11]=

Make custom edge tags by returning an association:

 In[12]:=
 Out[12]=

### Options (4)

#### StateLabeling (1)

Turn on special vertex shapes:

 In[13]:=
 Out[13]=

#### FormattingFunction (1)

Change the formatting for vertex 31:

 In[14]:=
 Out[14]=

#### RuleStyling (1)

Use custom styles for output values:

 In[15]:=
 Out[15]=

#### PostProcessGraph (1)

If the output is graphics with a legend, it useful to apply some custom function to the graph itself:

 In[16]:=
 Out[16]=

### Neat Examples (2)

Vertices can be number pairs:

 In[17]:=
 Out[17]=

For a remainder graph, to find 2143 (mod 7), start at 0 and follow (2143) to get remainder 1:

 In[18]:=
 Out[18]=

## Version History

• 2.0.1 – 03 October 2022
• 2.0.0 – 27 September 2022
• 1.1.0 – 11 January 2022