VertexList[g]
gives the list of vertices for the graph g.
VertexList[g,patt]
gives a list of vertices that match the pattern patt.
VertexList[{vw,…},…]
uses rules vw to specify the graph g.
VertexList
VertexList[g]
gives the list of vertices for the graph g.
VertexList[g,patt]
gives a list of vertices that match the pattern patt.
VertexList[{vw,…},…]
uses rules vw to specify the graph g.
Details
- VertexList is also known as nodes or actors.
- VertexList returns the list of vertices in the order used by the graph g.
Examples
open all close allBasic Examples (3)
The vertex list for an explicitly constructed graph:
Graph[{ab, bc, ca}]VertexList[%]The vertex list for a parametrically constructed graph:
VertexList[[image]]Find all vertices that match a pattern:
VertexList[[image], _ ? (# > 2&)]Scope (5)
VertexList works with undirected graphs:
VertexList[[image]]VertexList[[image]]Use rules to specify the graph:
VertexList[{1 -> 3, 2 -> 1, 3 -> 6, 4 -> 6, 1 -> 5, 5 -> 4, 6 -> 1}]Use patterns to select a subset of vertices:
g = Graph[{12, 21, a1, a2, b1, b2, bb}]VertexList[g, _Integer]VertexList[g, Except[_Integer]]VertexList works with large graphs:
g = GridGraph[{10, 10, 10, 10}];Timing[VertexList[g]//Length]Applications (2)
Find all vertices with a given annotation:
g = CompleteGraph[5, VertexStyle -> {1 -> Red, 2 -> Blue, 3 -> Red}, VertexSize -> Small]VertexList[g, _ ? (AnnotationValue[{g, #}, VertexStyle] == Red&)]Highlight the vertex by the vertex degree:
g = GridGraph[{10, 10}, VertexSize -> Large];vd = VertexDegree[g];HighlightGraph[g, Table[Style[VertexList[g][[i]], ColorData["TemperatureMap"][vd[[i]] / Max[vd]]], {i, VertexCount[g]}]]Properties & Relations (7)
VertexCount can be found using VertexList:
g = CompleteGraph[5]VertexCount[g]Length[VertexList[g]]VertexIndex gives the position of a vertex in VertexList:
g = Graph[{"a""c", "a""b", "b""c"}]Position[VertexList[g], "c"]VertexIndex[g, "c"]Use VertexQ to test if a vertex is a member of VertexList:
g = GridGraph[{3, 3}];MemberQ[VertexList[g], 8]VertexQ[g, 8]Vertices are taken in the order they appear in the list of edges:
Graph[{23, 12, 31, 41}]VertexList[%]The order can be modified with an explicit vertex list:
Graph[{1, 2, 3, 4}, {23, 12, 31, 41}]VertexList[%]Rows and columns of the adjacency matrix follow the order given by VertexList:
g = [image];VertexList[g]TableForm[Normal@(a = AdjacencyMatrix[g]), TableHeadings -> {c = Style[#, Red]& /@ %, c}]Rows of the incidence matrix correspond to VertexList:
g = [image];VertexList[g]TableForm[Normal@(m = IncidenceMatrix[g]), TableHeadings -> {Style[#, Red]& /@ VertexList[g], EdgeList[g]}]Vertices can be specified in Graph:
Graph[{a, b, c}, {ab, bc, ca}]VertexList[%]AdjacencyGraph[{a, b, c}, {{0, 1, 1}, {1, 0, 1}, {1, 1, 0}}]VertexList[%]IncidenceGraph[{a, b, c}, {{1, 1, 0}, {1, 0, 1}, {0, 1, 1}}]VertexList[%]Related Guides
Text
Wolfram Research (2010), VertexList, Wolfram Language function, https://reference.wolfram.com/language/ref/VertexList.html (updated 2015).
CMS
Wolfram Language. 2010. "VertexList." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/VertexList.html.
APA
Wolfram Language. (2010). VertexList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VertexList.html
BibTeX
@misc{reference.wolfram_2026_vertexlist, author="Wolfram Research", title="{VertexList}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/VertexList.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_vertexlist, organization={Wolfram Research}, title={VertexList}, year={2015}, url={https://reference.wolfram.com/language/ref/VertexList.html}, note=[Accessed: 13-June-2026]}