Function Repository Resource:

# NestWhileGraph (1.0.0)current version: 1.0.1 »

Iteratively construct graphs up to a termination condition

 ResourceFunction["NestWhileGraph"][f,expr,test] generates a directed graph whose nodes are obtained by applying f repeatedly, starting from expr, and continuing until applying test to the result no longer yields True. ResourceFunction["NestWhileGraph"][f,expr,test,m] supplies a list of the most recent m results to test at each step. ResourceFunction["NestWhileGraph"][f,expr,test,All] supplies a list of all results so far to test at each step. ResourceFunction["NestWhileGraph"][f,expr,test,m,max] applies f at most max times.

## Details

ResourceFunction["NestWhileGraph"] accepts all the options of Graph.
When testing on more than one successive graph, results are time ordered with older results occurring earlier in the list.
ResourceFunction["NestWhileGraph"] accepts all the options of Graph.
Setting DirectedEdges False returns an undirected graph.
Typically iterator f should be a list-valued function whose elements are also valid inputs to f.
Then the most general form for a typical output allows internal cycles.
If iteration returns to a previously visited value, it does not use that value as an input at the next step.
Thus, output graphs should not have duplicate edges.

## Examples

### Basic Examples (3)

Construct a graph by applying f while VertexCount is less than 5:

 In[1]:=
 Out[1]=

Apply a similar termination condition only to growth-front subgraph:

 In[2]:=
 Out[2]=

Terminate the growth of a graph according to properties of its vertex set:

 In[3]:=
 Out[3]=

Explore a grid graph through multiway spacetime evolution until every vertex has been visited:

 In[4]:=
 Out[4]=

Generate a torus graph:

 In[5]:=
 Out[5]=

Generate a few different Cayley graphs for the Octahedral group:

 In[6]:=
 Out[6]=

### Scope (1)

When setting DirectedEdges to False, outputs become undirected graphs:

 In[7]:=
 Out[7]=

### Options (1)

Termination can also be accomplished by introducing a cutoff for recursion depth:

 In[8]:=
 Out[8]=

### Neat Examples (2)

Construct the game graph of a loopy game:

 In[9]:=
 Out[9]=

Find loops in the game graph:

 In[10]:=
 Out[10]=

Generate a graph with structure related to prime numbers:

 In[11]:=
 Out[11]=

Notice false positives on the growth front:

 In[12]:=
 Out[12]=

## Version History

• 1.0.1 – 05 July 2022
• 1.0.0 – 10 June 2022