Wolfram Language & System 10.3 (2015)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

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 , , .

NestGraph[f,graph,n]
gives the graph obtained by applying f to the vertices of graph and extending the graph.

Details and OptionsDetails 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 , where evaluates to .
  • 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 are the vertices of graph.
  • NestGraph[f,graph,n] is the union of and NestGraph[f,{v1,}], where are the vertices of .
  • 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.

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

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

In[3]:=
Click for copyable input
Out[3]=

The function to nest can be a pure function:

In[1]:=
Click for copyable input
Out[1]=

Generate a binary tree of nested functions:

In[1]:=
Click for copyable input
Out[1]=

Generate a graph of neighboring countries around Switzerland:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2015
(10.2)