IndexGraph[g]
replaces the vertices of the graph g by its vertex indices.
IndexGraph[g,r]
replaces the vertices with integers r, r+1, ….
IndexGraph[{vw,…},…]
uses rules vw to specify the graph g.
IndexGraph
IndexGraph[g]
replaces the vertices of the graph g by its vertex indices.
IndexGraph[g,r]
replaces the vertices with integers r, r+1, ….
IndexGraph[{vw,…},…]
uses rules vw to specify the graph g.
Details and Options
- IndexGraph works with undirected graphs, directed graphs, multigraphs, and mixed graphs.
Examples
open all close allBasic Examples (2)
Scope (7)
IndexGraph works with undirected graphs:
IndexGraph[[image], 10]IndexGraph[[image], 10]IndexGraph[[image], 10]IndexGraph[[image], 10]Replace the vertices with negative indices:
IndexGraph[[image], -10]Use rules to specify the graph:
IndexGraph[{1 -> 3, 2 -> 1, 3 -> 6, 4 -> 6, 1 -> 5, 5 -> 4, 6 -> 1}, 10]IndexGraph works with large graphs:
g = GridGraph[{10, 10, 10, 10}];Timing[h = IndexGraph[g, VertexCount[g] + 1];]{VertexCount[h], EdgeCount[h]}Properties & Relations (5)
IndexGraph has the same number of vertices as the original graph:
g = [image];VertexCount[g] == VertexCount[IndexGraph[g, 10]]IndexGraph has the same number of edges as the original graph:
g = [image];EdgeCount[g] == EdgeCount[IndexGraph[g, 10]]IndexGraph is isomorphic to the original graph:
g = [image];IsomorphicGraphQ[g, IndexGraph[g, 20]]Use VertexReplace to replace the vertices of the graph:
{VertexReplace[[image], {1 -> 5, 2 -> 6, 3 -> 7, 4 -> 8}], IndexGraph[[image], 5]}IndexGraph has the same adjacency matrix as the original graph:
g = RandomGraph[{10, 20}]MatrixPlot[AdjacencyMatrix[#]]& /@ {g, IndexGraph[g, 20]}See Also
Related Guides
Text
Wolfram Research (2010), IndexGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/IndexGraph.html (updated 2015).
CMS
Wolfram Language. 2010. "IndexGraph." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/IndexGraph.html.
APA
Wolfram Language. (2010). IndexGraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/IndexGraph.html
BibTeX
@misc{reference.wolfram_2026_indexgraph, author="Wolfram Research", title="{IndexGraph}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/IndexGraph.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_indexgraph, organization={Wolfram Research}, title={IndexGraph}, year={2015}, url={https://reference.wolfram.com/language/ref/IndexGraph.html}, note=[Accessed: 13-June-2026]}