Skip to content

CycleGraph ​

The cycle graph CnC_n — nn vertices joined in a ring.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageCycleGraph!
CycleGraph(n)CnC_n (n≥3n \geq 3), vertices 1,…,n1, \dots, n, each joined to its neighbours around the ring.
Typed signatures
TypePackageApplies
(integer) -> valuecombinatoricsalways

Domain: Collections

Examples

Basic #

An odd cycle is never bipartite

live ↗
InIsBipartiteGraph(CycleGraph(5))\mathrm{IsBipartiteGraph}(\mathrm{CycleGraph}(5))OutFalse\mathrm{False}

An even cycle is bipartite

live ↗
InIsBipartiteGraph(CycleGraph(6))\mathrm{IsBipartiteGraph}(\mathrm{CycleGraph}(6))OutTrue\mathrm{True}
Scope #

The 3-cycle is a triangle

live ↗
InCycleGraph(3)\mathrm{CycleGraph}(3)OutGraph([1,2,3],[UndirectedEdge(1,2),UndirectedEdge(2,3),UndirectedEdge(3,1)])\mathrm{Graph}(\bigl\lbrack1, 2, 3\bigr\rbrack, \bigl\lbrack\mathrm{UndirectedEdge}(1, 2), \mathrm{UndirectedEdge}(2, 3), \mathrm{UndirectedEdge}(3, 1)\bigr\rbrack)
Applications #

On a 5-cycle the farthest vertex is 2 steps away

live ↗
InMap(()↦VertexEccentricity(CycleGraph(5),_1⁡),VertexList(CycleGraph(5)))\mathrm{Map}(()↦\mathrm{VertexEccentricity}(\mathrm{CycleGraph}(5), \operatorname{\_1}), \mathrm{VertexList}(\mathrm{CycleGraph}(5)))Out[2,2,2,2,2]\bigl\lbrack2, 2, 2, 2, 2\bigr\rbrack
Properties #

A cycle graph contains a cycle, so not acyclic

live ↗
InIsAcyclicGraph(CycleGraph(5))\mathrm{IsAcyclicGraph}(\mathrm{CycleGraph}(5))OutFalse\mathrm{False}

Every vertex has degree 2

live ↗
InVertexDegree(CycleGraph(7))\mathrm{VertexDegree}(\mathrm{CycleGraph}(7))Out[2,2,2,2,2,2,2]\bigl\lbrack2, 2, 2, 2, 2, 2, 2\bigr\rbrack

Four vertices joined in a ring

live ↗
InCycleGraph(4)\mathrm{CycleGraph}(4)OutGraph([1,2,3,4],[UndirectedEdge(1,2),UndirectedEdge(2,3),UndirectedEdge(3,4),UndirectedEdge(4,1)])\mathrm{Graph}(\bigl\lbrack1, 2, 3, 4\bigr\rbrack, \bigl\lbrack\mathrm{UndirectedEdge}(1, 2), \mathrm{UndirectedEdge}(2, 3), \mathrm{UndirectedEdge}(3, 4), \mathrm{UndirectedEdge}(4, 1)\bigr\rbrack)
live ↗
InIsPathGraph(CycleGraph(5))\mathrm{IsPathGraph}(\mathrm{CycleGraph}(5))OutFalse\mathrm{False}
About
Examples8
Checked againstWolfram Language 7 agree1 differ
CrosswalkWolfram Language

See also: PathGraph, IsBipartiteGraph