# NestGraph

NestGraph[f,expr,n]

gives the graph obtained by starting with expr and applying f successively n times.

NestGraph[f,{expr1,expr2,},n]

gives the graph obtained by applying f to expr1, expr2, .

NestGraph[f,graph,n]

gives the graph obtained by applying f to the vertices of graph and extending the graph.

# Details and Options • NestGraph is also known as crawl graph or tree growing.
• expr can be an expression or a list of expressions or graphs.
• NestGraph[f,expr] is equivalent to NestGraph[f,expr,1].
• NestGraph[f,expr] gives a graph with edges {exprexpr1,,exprexprk}, where f[expr] evaluates to {expr1,,exprk}.
• NestGraph[f,{expr1,expr2,}] is the graph union of NestGraph[f,expr1] and NestGraph[f,expr2],.
• NestGraph[f,graph] is the union of graph and NestGraph[f,{v1,}], where vi are the vertices of graph.
• NestGraph[f,graph,n] is the union of NestGraph[f,graph,n-1] and NestGraph[f,{v1,}], where vi are the vertices of NestGraph[f,graph,n-1].
• NestGraph[f,expr,n] is equivalent to NestGraph[f,graph,n], where graph is the singleton graph with only one vertex expr and no edges.
• NestGraph takes the same options as Graph.
• The option DirectedEdges can be used to control whether an undirected or directed graph is constructed.

# Examples

open all close all

## Basic Examples(4)

Construct a graph by starting with x and applying f successively 3 times:

 In:= Out= The function to nest can be a pure function:

 In:= Out= Generate a binary tree of nested functions:

 In:= Out= Generate a graph of neighboring countries around Switzerland:

 In:= Out= ## Neat Examples(1)

Introduced in 2015
(10.2)