TorusGraph
✖
TorusGraph
Details and Options

- TorusGraph is also known as toroidal graph.
- TorusGraph[{n1,n2,…,nk}] gives a graph formed from the graph Cartesian product of the cycle graphs
.
- TorusGraph[{n1,n2,…,nk},DirectedEdges->True] gives a directed torus graph.
- TorusGraph takes the same options as Graph.
-
AlignmentPoint Center the default point in the graphic to align with AnnotationRules {} annotations for graph, edges and vertices AspectRatio Automatic ratio of height to width Axes False whether to draw axes AxesLabel None axes labels AxesOrigin Automatic where axes should cross AxesStyle {} style specifications for the axes Background None background color for the plot BaselinePosition Automatic how to align with a surrounding text baseline BaseStyle {} base style specifications for the graphic ContentSelectable Automatic whether to allow contents to be selected CoordinatesToolOptions Automatic detailed behavior of the coordinates tool DirectedEdges Automatic whether to interpret Rule as DirectedEdge EdgeLabels None labels and label placements for edges EdgeLabelStyle Automatic style to use for edge labels EdgeShapeFunction Automatic generate graphic shapes for edges EdgeStyle Automatic style used for edges EdgeWeight Automatic weights for edges Epilog {} primitives rendered after the main plot FormatType TraditionalForm the default format type for text Frame False whether to put a frame around the plot FrameLabel None frame labels FrameStyle {} style specifications for the frame FrameTicks Automatic frame ticks FrameTicksStyle {} style specifications for frame ticks GraphHighlight {} graph elements to highlight GraphHighlightStyle Automatic style for highlight GraphLayout Automatic how to lay out vertices and edges GridLines None grid lines to draw GridLinesStyle {} style specifications for grid lines ImageMargins 0. the margins to leave around the graphic ImagePadding All what extra padding to allow for labels etc. ImageSize Automatic the absolute size at which to render the graphic LabelStyle {} style specifications for labels Method Automatic details of graphics methods to use PerformanceGoal Automatic aspects of performance to try to optimize PlotLabel None an overall label for the plot PlotRange All range of values to include PlotRangeClipping False whether to clip at the plot range PlotRangePadding Automatic how much to pad the range of values PlotRegion Automatic the final display region to be filled PlotTheme $PlotTheme overall theme for the graph PreserveImageOptions Automatic whether to preserve image options when displaying new versions of the same graphic Prolog {} primitives rendered before the main plot RotateLabel True whether to rotate y labels on the frame Ticks Automatic axes ticks TicksStyle {} style specifications for axes ticks VertexCoordinates Automatic coordinates for vertices VertexLabels None labels and placements for vertices VertexLabelStyle Automatic style to use for vertex labels VertexShape Automatic graphic shape for vertices VertexShapeFunction Automatic generate graphic shapes for vertices VertexSize Medium size of vertices VertexStyle Automatic styles for vertices VertexWeight Automatic weights for vertices

List of all options




Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Scope (2)Survey of the scope of standard use cases
Generate a k-dimensional torus graph:

https://wolfram.com/xid/0puwebqgs6-c2453e


https://wolfram.com/xid/0puwebqgs6-17s5v5


https://wolfram.com/xid/0puwebqgs6-h4impo


https://wolfram.com/xid/0puwebqgs6-b7dw5k


https://wolfram.com/xid/0puwebqgs6-2wwkhj

Generate a directed torus graph:

https://wolfram.com/xid/0puwebqgs6-0ww8tt

Options (83)Common values & functionality for each option
AnnotationRules (3)
DirectedEdges (1)
By default, an undirected graph is generated:

https://wolfram.com/xid/0puwebqgs6-iwq8nh

Use DirectedEdges->True to generate a directed graph:

https://wolfram.com/xid/0puwebqgs6-hsbm48

EdgeLabels (7)

https://wolfram.com/xid/0puwebqgs6-z5279


https://wolfram.com/xid/0puwebqgs6-1t3zd


https://wolfram.com/xid/0puwebqgs6-hr4015

Use any expression as a label:

https://wolfram.com/xid/0puwebqgs6-b7zkda

Use Placed with symbolic locations to control label placement along an edge:

https://wolfram.com/xid/0puwebqgs6-fnltmw

Use explicit coordinates to place labels:

https://wolfram.com/xid/0puwebqgs6-ndfa94

Vary positions within the label:

https://wolfram.com/xid/0puwebqgs6-bg84f5


https://wolfram.com/xid/0puwebqgs6-33q72


https://wolfram.com/xid/0puwebqgs6-hb7fqh

Use automatic labeling by values through Tooltip and StatusArea:

https://wolfram.com/xid/0puwebqgs6-dhn5kr


https://wolfram.com/xid/0puwebqgs6-bd54a9

EdgeShapeFunction (6)
Get a list of built-in settings for EdgeShapeFunction:

https://wolfram.com/xid/0puwebqgs6-idb88j

Undirected edges including the basic line:

https://wolfram.com/xid/0puwebqgs6-d5iw86

Lines with different glyphs on the edges:

https://wolfram.com/xid/0puwebqgs6-mdmtah

Directed edges including solid arrows:

https://wolfram.com/xid/0puwebqgs6-ofd04w


https://wolfram.com/xid/0puwebqgs6-nqgh3t


https://wolfram.com/xid/0puwebqgs6-dtoh30

Specify an edge function for an individual edge:

https://wolfram.com/xid/0puwebqgs6-bxr21q

Combine with a different default edge function:

https://wolfram.com/xid/0puwebqgs6-bbvsg0

Draw edges by running a program:

https://wolfram.com/xid/0puwebqgs6-fgtdlv

https://wolfram.com/xid/0puwebqgs6-jbbc2c

EdgeShapeFunction can be combined with EdgeStyle:

https://wolfram.com/xid/0puwebqgs6-mizuan

EdgeShapeFunction has higher priority than EdgeStyle:

https://wolfram.com/xid/0puwebqgs6-jq8ajw

EdgeStyle (2)
EdgeWeight (3)
Specify a weight for all edges:

https://wolfram.com/xid/0puwebqgs6-8fxi6


https://wolfram.com/xid/0puwebqgs6-baprxk

Use any numeric expression as a weight:

https://wolfram.com/xid/0puwebqgs6-bcptub


https://wolfram.com/xid/0puwebqgs6-fibbsw

Specify weights for individual edges:

https://wolfram.com/xid/0puwebqgs6-dus88r


https://wolfram.com/xid/0puwebqgs6-c3ozib

GraphHighlight (3)
GraphHighlightStyle (2)
Get a list of built-in settings for GraphHighlightStyle:

https://wolfram.com/xid/0puwebqgs6-lu7p68

Use built-in settings for GraphHighlightStyle:

https://wolfram.com/xid/0puwebqgs6-qwjuvn

GraphLayout (5)
By default, the layout is chosen automatically:

https://wolfram.com/xid/0puwebqgs6-dk5p2q

Specify layouts on special curves:

https://wolfram.com/xid/0puwebqgs6-bh0brv

Specify layouts that satisfy optimality criteria:

https://wolfram.com/xid/0puwebqgs6-fxlux1

VertexCoordinates overrides GraphLayout coordinates:

https://wolfram.com/xid/0puwebqgs6-nc1kzc

Use AbsoluteOptions to extract VertexCoordinates computed using a layout algorithm:

https://wolfram.com/xid/0puwebqgs6-ndu6b


https://wolfram.com/xid/0puwebqgs6-ebyn3r

PlotTheme (4)
Base Themes (2)
VertexCoordinates (3)
By default, any vertex coordinates are computed automatically:

https://wolfram.com/xid/0puwebqgs6-5spor

Extract the resulting vertex coordinates using AbsoluteOptions:

https://wolfram.com/xid/0puwebqgs6-2whoh

Specify a layout function along an ellipse:

https://wolfram.com/xid/0puwebqgs6-mwyuvu

https://wolfram.com/xid/0puwebqgs6-cvx31k

Use it to generate vertex coordinates for a graph:

https://wolfram.com/xid/0puwebqgs6-uukkr

VertexCoordinates has higher priority than GraphLayout:

https://wolfram.com/xid/0puwebqgs6-hdij4u

VertexLabels (13)

https://wolfram.com/xid/0puwebqgs6-c9ka50


https://wolfram.com/xid/0puwebqgs6-i40mcj


https://wolfram.com/xid/0puwebqgs6-whkpg

Use any expression as a label:

https://wolfram.com/xid/0puwebqgs6-kokbex

Use Placed with symbolic locations to control label placement, including outside positions:

https://wolfram.com/xid/0puwebqgs6-csc6y

Symbolic outside corner positions:

https://wolfram.com/xid/0puwebqgs6-405x2

https://wolfram.com/xid/0puwebqgs6-fjgxt8


https://wolfram.com/xid/0puwebqgs6-fg0pin

Symbolic inside corner positions:

https://wolfram.com/xid/0puwebqgs6-kfrv7

https://wolfram.com/xid/0puwebqgs6-dr87wv

Use explicit coordinates to place the center of labels:

https://wolfram.com/xid/0puwebqgs6-cqfi4r

Place all labels at the upper-right corner of the vertex and vary the coordinates within the label:

https://wolfram.com/xid/0puwebqgs6-20sv


https://wolfram.com/xid/0puwebqgs6-kusfg3

Any number of labels can be used:

https://wolfram.com/xid/0puwebqgs6-fqezh

Use the argument to Placed to control formatting including Tooltip:

https://wolfram.com/xid/0puwebqgs6-hg8fi6

Or StatusArea:

https://wolfram.com/xid/0puwebqgs6-iyk99o

Use more elaborate formatting functions:

https://wolfram.com/xid/0puwebqgs6-bd9m40

https://wolfram.com/xid/0puwebqgs6-cggp96


https://wolfram.com/xid/0puwebqgs6-l3s7yb

https://wolfram.com/xid/0puwebqgs6-cljxny


https://wolfram.com/xid/0puwebqgs6-cqkdbb

https://wolfram.com/xid/0puwebqgs6-bjoam1

VertexShape (5)
Use any Graphics, Image or Graphics3D as a vertex shape:

https://wolfram.com/xid/0puwebqgs6-dvz661

Specify vertex shapes for individual vertices:

https://wolfram.com/xid/0puwebqgs6-i1s9c7

VertexShape can be combined with VertexSize:

https://wolfram.com/xid/0puwebqgs6-jqe83v

VertexShape is not affected by VertexStyle:

https://wolfram.com/xid/0puwebqgs6-3ef8f

VertexShapeFunction has higher priority than VertexShape:

https://wolfram.com/xid/0puwebqgs6-budnxj

VertexShapeFunction (10)
Get a list of built-in collections for VertexShapeFunction:

https://wolfram.com/xid/0puwebqgs6-b5rwf2

Use built-in settings for VertexShapeFunction in the "Basic" collection:

https://wolfram.com/xid/0puwebqgs6-cgc16d


https://wolfram.com/xid/0puwebqgs6-fiwomp


https://wolfram.com/xid/0puwebqgs6-o7ui5

Use built-in settings for VertexShapeFunction in the "Rounded" collection:

https://wolfram.com/xid/0puwebqgs6-ej0qi


https://wolfram.com/xid/0puwebqgs6-bpj7ch

Use built-in settings for VertexShapeFunction in the "Concave" collection:

https://wolfram.com/xid/0puwebqgs6-uqe4m


https://wolfram.com/xid/0puwebqgs6-dvgf5e


https://wolfram.com/xid/0puwebqgs6-b755hd

Combine with a default vertex function:

https://wolfram.com/xid/0puwebqgs6-eyx6

Draw vertices using a predefined graphic:

https://wolfram.com/xid/0puwebqgs6-ftmxow

Draw vertices by running a program:

https://wolfram.com/xid/0puwebqgs6-chy1fh

https://wolfram.com/xid/0puwebqgs6-fg1dof

VertexShapeFunction can be combined with VertexStyle:

https://wolfram.com/xid/0puwebqgs6-bofgbk

https://wolfram.com/xid/0puwebqgs6-k3ulhf

VertexShapeFunction has higher priority than VertexStyle:

https://wolfram.com/xid/0puwebqgs6-ey9v0k

https://wolfram.com/xid/0puwebqgs6-b690yq

VertexShapeFunction can be combined with VertexSize:

https://wolfram.com/xid/0puwebqgs6-ia0yg1

VertexShapeFunction has higher priority than VertexShape:

https://wolfram.com/xid/0puwebqgs6-jewlcq

VertexSize (8)
By default, the size of vertices is computed automatically:

https://wolfram.com/xid/0puwebqgs6-dsy1ve

Specify the size of all vertices using symbolic vertex size:

https://wolfram.com/xid/0puwebqgs6-lskxsr

Use a fraction of the minimum distance between vertex coordinates:

https://wolfram.com/xid/0puwebqgs6-3lxk1

Use a fraction of the overall diagonal for all vertex coordinates:

https://wolfram.com/xid/0puwebqgs6-my5omo

Specify size in both the and
directions:

https://wolfram.com/xid/0puwebqgs6-c7twgs

Specify the size for individual vertices:

https://wolfram.com/xid/0puwebqgs6-h6r4ja

VertexSize can be combined with VertexShapeFunction:

https://wolfram.com/xid/0puwebqgs6-lmhpww

VertexSize can be combined with VertexShape:

https://wolfram.com/xid/0puwebqgs6-dego1v

VertexStyle (5)

https://wolfram.com/xid/0puwebqgs6-ehbi7i


https://wolfram.com/xid/0puwebqgs6-dtkst6

VertexShapeFunction can be combined with VertexStyle:

https://wolfram.com/xid/0puwebqgs6-om30z

https://wolfram.com/xid/0puwebqgs6-nnfnwx

VertexShapeFunction has higher priority than VertexStyle:

https://wolfram.com/xid/0puwebqgs6-kfv4n

https://wolfram.com/xid/0puwebqgs6-cldcke

VertexStyle can be combined with BaseStyle:

https://wolfram.com/xid/0puwebqgs6-bby1h9

VertexStyle has higher priority than BaseStyle:

https://wolfram.com/xid/0puwebqgs6-d0df6

VertexShape is not affected by VertexStyle:

https://wolfram.com/xid/0puwebqgs6-3rqw0

VertexWeight (3)
Set the weight for all vertices:

https://wolfram.com/xid/0puwebqgs6-coy9ti


https://wolfram.com/xid/0puwebqgs6-jjkrix

Specify the weight for individual vertices:

https://wolfram.com/xid/0puwebqgs6-b1lkq5


https://wolfram.com/xid/0puwebqgs6-pafq61

Use any numeric expression as a weight:

https://wolfram.com/xid/0puwebqgs6-lxjpz1


https://wolfram.com/xid/0puwebqgs6-ckzgu5

Applications (11)Sample problems that can be solved with this function
Basic Applications (6)

https://wolfram.com/xid/0puwebqgs6-309qmr

Style vertices and edges of a torus graph:

https://wolfram.com/xid/0puwebqgs6-ji7zqg

Annotate vertices and edges of a torus graph:

https://wolfram.com/xid/0puwebqgs6-ppixl

https://wolfram.com/xid/0puwebqgs6-xodvq1


https://wolfram.com/xid/0puwebqgs6-7vfk0s

Modify a torus graph parameters:

https://wolfram.com/xid/0puwebqgs6-8xu4xp


https://wolfram.com/xid/0puwebqgs6-9fwthq


https://wolfram.com/xid/0puwebqgs6-05o64l

Generate a torus graph represented as a 3D plot:

https://wolfram.com/xid/0puwebqgs6-zmdool

Basic properties of the torus graph; the number of vertices:

https://wolfram.com/xid/0puwebqgs6-dh07t


https://wolfram.com/xid/0puwebqgs6-uqxem7

Graph Theory (5)
Adjacency matrices are banded for a torus graph:

https://wolfram.com/xid/0puwebqgs6-zecaep

Assign distinct colors to adjacent vertices of a torus graph:

https://wolfram.com/xid/0puwebqgs6-4jz52

https://wolfram.com/xid/0puwebqgs6-kxwmt3


https://wolfram.com/xid/0puwebqgs6-b4fkus

Assign distinct colors to adjacent edges of a torus graph:

https://wolfram.com/xid/0puwebqgs6-s48ogv

https://wolfram.com/xid/0puwebqgs6-cqc1uy


https://wolfram.com/xid/0puwebqgs6-1rqn74

Find the shortest tour in a simple torus graph:

https://wolfram.com/xid/0puwebqgs6-3gl0mt

https://wolfram.com/xid/0puwebqgs6-uud6n9


https://wolfram.com/xid/0puwebqgs6-d3j6vr

Find a spanning tree in a torus graph:

https://wolfram.com/xid/0puwebqgs6-e7nzw7

https://wolfram.com/xid/0puwebqgs6-zz53rg

https://wolfram.com/xid/0puwebqgs6-rugbpc

Properties & Relations (6)Properties of the function, and connections to other functions
TorusGraph[{n1,n2,…}] has self-loops if one of is 1:

https://wolfram.com/xid/0puwebqgs6-wjp7f0


https://wolfram.com/xid/0puwebqgs6-3w7op1

TorusGraph[{n1,n2,…}] has parallel edges if one of is 2:

https://wolfram.com/xid/0puwebqgs6-si43od


https://wolfram.com/xid/0puwebqgs6-5h6e8s

TorusGraph[{n}] is a cycle graph:

https://wolfram.com/xid/0puwebqgs6-eqm9zs

TorusGraph[{m,n}] is the graph formed from the Cartesian product of the cycle graphs and
:

https://wolfram.com/xid/0puwebqgs6-2xqjjb


https://wolfram.com/xid/0puwebqgs6-l8vjru

TorusGraph has the same number of vertices as GridGraph:

https://wolfram.com/xid/0puwebqgs6-tvljif

The difference between the number of edges of TorusGraph[f] and GridGraph[f]:

https://wolfram.com/xid/0puwebqgs6-0zm0ky

https://wolfram.com/xid/0puwebqgs6-z5l5lb


https://wolfram.com/xid/0puwebqgs6-foq3hc

Possible Issues (1)Common pitfalls and unexpected behavior
Large torus graphs do not automatically display as a plot of graph:

https://wolfram.com/xid/0puwebqgs6-0o45z1

Use GraphPlot to plot the graph:

https://wolfram.com/xid/0puwebqgs6-t57jhp

Interactive Examples (1)Examples with interactive outputs
Neat Examples (1)Surprising or curious use cases

https://wolfram.com/xid/0puwebqgs6-e96qv8

Wolfram Research (2022), TorusGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/TorusGraph.html.
Text
Wolfram Research (2022), TorusGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/TorusGraph.html.
Wolfram Research (2022), TorusGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/TorusGraph.html.
CMS
Wolfram Language. 2022. "TorusGraph." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TorusGraph.html.
Wolfram Language. 2022. "TorusGraph." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TorusGraph.html.
APA
Wolfram Language. (2022). TorusGraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TorusGraph.html
Wolfram Language. (2022). TorusGraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TorusGraph.html
BibTeX
@misc{reference.wolfram_2025_torusgraph, author="Wolfram Research", title="{TorusGraph}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/TorusGraph.html}", note=[Accessed: 07-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_torusgraph, organization={Wolfram Research}, title={TorusGraph}, year={2022}, url={https://reference.wolfram.com/language/ref/TorusGraph.html}, note=[Accessed: 07-May-2025
]}