This resource function is obsolete. Use the function TorusGraph instead.

Function Repository Resource:

TorusGraph

Source Notebook

Create a grid graph of any dimension with the topology of a torus

Contributed by: Stephen Wolfram

ResourceFunction["TorusGraph"][{n1,n2,,nk}]

gives the k-dimensional toroidal grid graph with n1×n2××nk vertices.

Details and Options

ResourceFunction["TorusGraph"][{n1,n2,,nk},DirectedEdgesTrue] gives a directed toroidal grid graph.
TorusGraph takes the same options as Graph.

Examples

Basic Examples (1) 

Make a 10×5 toroidal grid graph:

In[1]:=
ResourceFunction["TorusGraph"][{10, 5}]
Out[1]=

Scope (2) 

Create a one-dimensional toroidal grid graph:

In[2]:=
ResourceFunction["TorusGraph"][{10}]
Out[2]=

Create a three-dimensional toroidal grid graph:

In[3]:=
ResourceFunction["TorusGraph"][{3, 3, 3}]
Out[3]=

Visualize the torus graph in 3D:

In[4]:=
Graph3D[ResourceFunction["TorusGraph"][{10, 5}], GraphLayout -> "SpringElectricalEmbedding"]
Out[4]=

Options (1) 

DirectedEdges (1) 

Use directed edges:

In[5]:=
ResourceFunction["TorusGraph"][{6}, DirectedEdges -> True]
Out[5]=
In[6]:=
ResourceFunction["TorusGraph"][{6, 8}, DirectedEdges -> True]
Out[6]=

Properties and Relations (2) 

Compare a grid graph to a toroidal grid graph:

In[7]:=
{GridGraph[{2, 2}], ResourceFunction["TorusGraph"][{2, 2}]}
Out[7]=
In[8]:=
{GridGraph[{2, 2, 2}], ResourceFunction["TorusGraph"][{2, 2, 2}]}
Out[8]=

A grid structure becomes increasingly visible for larger toroidal grid graphs:

In[9]:=
LayeredGraphPlot[ResourceFunction["TorusGraph"][{10, 10}]]
Out[9]=

Version History

  • 2.0.0 – 18 March 2020
  • 1.0.0 – 04 December 2019

Related Resources

License Information