AdjacencyList[g,v]
gives a list of vertices adjacent to vertex v.
AdjacencyList[g,patt]
gives a list of vertices adjacent to vertices that match the pattern patt.
AdjacencyList[g,patt,d]
gives a list of vertices that are at distance at most d.
AdjacencyList[{vw,…},…]
uses rules vw to specify the graph g.
AdjacencyList
AdjacencyList[g,v]
gives a list of vertices adjacent to vertex v.
AdjacencyList[g,patt]
gives a list of vertices adjacent to vertices that match the pattern patt.
AdjacencyList[g,patt,d]
gives a list of vertices that are at distance at most d.
AdjacencyList[{vw,…},…]
uses rules vw to specify the graph g.
Details
- AdjacencyList is typically used to represent the neighbors of each vertex.
- AdjacencyList returns the list of vertices in the order used by the graph g.
- AdjacencyList[g,v] is equivalent to AdjacencyList[g,v,1].
- AdjacencyList[g] gives the list of adjacent vertices to each vertex of g.
- AdjacencyList[g,All] is effectively equivalent to AdjacencyList[g].
Examples
open all close allBasic Examples (3)
A list of vertices adjacent to the vertex 1:
AdjacencyList[[image], 1]Find all vertices adjacent to vertices that match a pattern:
AdjacencyList[[image], _ ? (# < 3&)]g = GridGraph[{11, 11}, VertexSize -> 0.6, VertexStyle -> {61 -> Blue}];Table[HighlightGraph[g, AdjacencyList[g, 61, i]], {i, 3}]Scope (6)
AdjacencyList works with undirected graphs:
AdjacencyList[[image], 1]AdjacencyList[[image], 1]Use rules to specify the graph:
AdjacencyList[{1 -> 3, 2 -> 1, 3 -> 6, 4 -> 6, 1 -> 5, 5 -> 4, 6 -> 1}, 1]Use patterns to select a subset of vertices:
AdjacencyList[[image], _Integer]Find vertices at a distance 2 from vertex 1:
AdjacencyList[[image], 1, 2]AdjacencyList works with large graphs:
g = GridGraph[{10, 10, 10, 10}];AdjacencyList[g, 100]//TimingApplications (1)
A family network consisting of the closest relatives, including parents, siblings, and children:
g = ExampleData[{"NetworkGraph", "FamilyGathering"}]Immediate family members of Nancy:
AdjacencyList[g, "Nancy"]HighlightGraph[g, %]Properties & Relations (2)
AdjacencyList can be found using NeighborhoodGraph:
g = [image];AdjacencyList[g, 1]VertexList[NeighborhoodGraph[g, 1], Except[1]]AdjacencyList can be found using IncidenceList:
g = [image];AdjacencyList[g, 2]DeleteCases[Flatten[List@@@IncidenceList[g, 2]], 2]Related Guides
Text
Wolfram Research (2012), AdjacencyList, Wolfram Language function, https://reference.wolfram.com/language/ref/AdjacencyList.html (updated 2018).
CMS
Wolfram Language. 2012. "AdjacencyList." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2018. https://reference.wolfram.com/language/ref/AdjacencyList.html.
APA
Wolfram Language. (2012). AdjacencyList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AdjacencyList.html
BibTeX
@misc{reference.wolfram_2026_adjacencylist, author="Wolfram Research", title="{AdjacencyList}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/AdjacencyList.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_adjacencylist, organization={Wolfram Research}, title={AdjacencyList}, year={2018}, url={https://reference.wolfram.com/language/ref/AdjacencyList.html}, note=[Accessed: 13-June-2026]}