Function Repository Resource:

AlternatingTreeGraph

Source Notebook

Construct an alternating tree graph

Contributed by: Peter Burbery

ResourceFunction["AlternatingTreeGraph"][n]

generates an alternating tree graph from a path graph with n vertices.

Details

An alternating tree J is a tree each of whose edges joins an inner vertex to an outer vertex so that each inner vertex of J meets exactly two edges of J.
An alternating tree graph has 3n-4 vertices.
ResourceFunction["AlternatingTreeGraph"] takes the same options as Graph.

Examples

Basic Examples (1) 

Make an alternating tree graph from the path graph with 10 vertices:

In[1]:=
ResourceFunction["AlternatingTreeGraph"][10]
Out[1]=

Scope (1) 

Create a large alternating tree graph:

In[2]:=
ResourceFunction["AlternatingTreeGraph"][200]
Out[2]=

Options (2) 

GraphLayout (2) 

All graph layouts can be selected:

In[3]:=
Table[Labeled[
  ResourceFunction["AlternatingTreeGraph"][10, GraphLayout -> embedding], embedding], {embedding, {"BipartiteEmbedding", "CircularEmbedding", "CircularMultipartiteEmbedding", "DiscreteSpiralEmbedding", "GridEmbedding", "LinearEmbedding", "MultipartiteEmbedding", "StarEmbedding", "BalloonEmbedding", "RadialEmbedding", "LayeredEmbedding", "GravityEmbedding", "HighDimensionalEmbedding",
    "SpectralEmbedding", "SphericalEmbedding", "SpringElectricalEmbedding", "SpringEmbedding", "TutteEmbedding"}}]
Out[3]=

Try SpringEmbedding if SpringElectricalEmbedding does not work well:

In[4]:=
ResourceFunction["AlternatingTreeGraph"][100]
Out[4]=
In[5]:=
ResourceFunction["AlternatingTreeGraph"][100, GraphLayout -> "SpringEmbedding"]
Out[5]=

Applications (1) 

Find the graph center and graph periphery:

In[6]:=
HighlightGraph[ResourceFunction["AlternatingTreeGraph"][12], GraphCenter[ResourceFunction["AlternatingTreeGraph"][12]]]
Out[6]=
In[7]:=
HighlightGraph[ResourceFunction["AlternatingTreeGraph"][12], GraphPeriphery[ResourceFunction["AlternatingTreeGraph"][12]]]
Out[7]=

Properties and Relations (2) 

Use FindSequenceFunction to find a pattern in the order and size of the graph:

In[8]:=
graphs = ResourceFunction["AlternatingTreeGraph"] /@ Range[4, 20]
Out[8]=
In[9]:=
FindSequenceFunction[VertexCount /@ graphs]
Out[9]=
In[10]:=
FindSequenceFunction[EdgeCount /@ graphs]
Out[10]=

Predict the size of a 2980 length alternating tree:

In[11]:=
graphs = ResourceFunction["AlternatingTreeGraph"] /@ Range[4, 20]
Out[11]=
In[12]:=
FindSequenceFunction[VertexCount /@ graphs][2980]
Out[12]=
In[13]:=
FindSequenceFunction[EdgeCount /@ graphs][2980]
Out[13]=

Publisher

Peter Burbery

Requirements

Wolfram Language 12.3 (May 2021) or above

Version History

  • 1.0.1 – 13 July 2023
  • 1.0.0 – 02 August 2022

Source Metadata

Related Resources

License Information