({{, (RefLink[IndexGraph, paclet:ref/IndexGraph])[g] 
replaces the vertices of the graph g by its vertex indexes.}, {, (RefLink[IndexGraph, paclet:ref/IndexGraph])[g,r]
replaces the vertices with integers r,  r+1, ….}, {, (RefLink[IndexGraph, paclet:ref/IndexGraph])[{v->w,…},…]
uses rules v->w to specify the graph g. }})

OpenersNotesSection(Spacer1)Details and Options

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

OpenersPrimaryExamplesSection(Spacer1)Examples  (14)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Replace the vertices of the graph with its vertex indexes:

IndexGraph[]

Replace the vertices with indexes starting from 6:

IndexGraph[,6]

OpenersExampleSection1(Spacer1)Scope  (7)

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

IndexGraph[,10]

Directed graphs:

IndexGraph[,10]

Multigraphs:

IndexGraph[,10]

Mixed graphs:

IndexGraph[,10]

Replace the vertices with negative indexes:

IndexGraph[,-10]

Use rules to specify the graph:

IndexGraph[{1->3,2->1,3->6,4->6,1->5,5->4,6->1},10]

(RefLink[IndexGraph, paclet:ref/IndexGraph]) works with large graphs:

g=GridGraph[{10,10,10,10}];

Timing[h=IndexGraph[g,VertexCount[g]+1];]

{VertexCount[h],EdgeCount[h]}

OpenersExampleSection4(Spacer1)Properties & Relations  (5)

(RefLink[IndexGraph, paclet:ref/IndexGraph]) has the same number of vertices as the original graph:

g=;

VertexCount[g]==VertexCount[IndexGraph[g,10]]

(RefLink[IndexGraph, paclet:ref/IndexGraph]) has the same number of edges as the original graph:

g=;

EdgeCount[g]==EdgeCount[IndexGraph[g,10]]

(RefLink[IndexGraph, paclet:ref/IndexGraph]) is isomorphic to the original graph:

g=;

IsomorphicGraphQ[g,IndexGraph[g,20]]

Use (RefLink[VertexReplace, paclet:ref/VertexReplace]) to replace the vertices of the graph:

{VertexReplace[,{1->5,2->6,3->7,4->8}],IndexGraph[,5]}

(RefLink[IndexGraph, paclet:ref/IndexGraph]) has the same adjacency matrix as the original graph:

g=RandomGraph[{10,20}]

MatrixPlot[AdjacencyMatrix[#]]&/@{g,IndexGraph[g,20]}

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

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