({{, (RefLink[GraphPower, paclet:ref/GraphPower])[g,n] 
gives the graph-n(^th) power of the graph g.}, {, (RefLink[GraphPower, paclet:ref/GraphPower])[{v->w,…},…]
uses rules v->w to specify the graph g.}})

OpenersNotesSection(Spacer1)Details and Options

The graph-n(^th) power has the same vertices, and vertex (Subscript[v, i]) is adjacent to vertex (Subscript[v, j]) only if there is a path of at most length n from (Subscript[v, i]) to (Subscript[v, j]).

(RefLink[GraphPower, paclet:ref/GraphPower]) works with undirected graphs, directed graphs, multigraphs, and mixed graphs.

OpenersPrimaryExamplesSection(Spacer1)Examples  (8)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Graph power of cycle graphs:

Table[CycleGraph[n],{n,4,6}]

GraphPower[#,2]&/@%

OpenersExampleSection1(Spacer1)Scope  (5)

(RefLink[GraphPower, paclet:ref/GraphPower]) works with undirected graphs:

GraphPower[,2]

Directed graphs:

GraphPower[,2]

Multigraphs:

GraphPower[,2]

Mixed graphs:

GraphPower[,2]

Use rules to specify the graph:

GraphPower[{1->2,2->3,3->1,3->4},2]

OpenersExampleSection4(Spacer1)Properties & Relations  (2)

Raising a connected graph to the power of its graph diameter gives a complete graph:

CycleGraph[7]

GraphPower[%, GraphDiameter[%]]

CompleteGraphQ[%]

Graph-k(^th) powers can be obtained by the sum of the first k powers of the adjacency matrix:

g = CycleGraph[7]

m= AdjacencyMatrix[g];

{GraphPower[g, 3],SimpleGraph[AdjacencyGraph[Clip[m+m.m+m.m.m]]]}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Graph, paclet:ref/Graph])  ▪  (RefLink[AdjacencyMatrix, paclet:ref/AdjacencyMatrix])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Graph Operations and Modifications, paclet:guide/GraphModifications])}})}})