NeighborhoodVertices[g,i,r]
gives vertices that can be reached from vertex i within r hops.
NeighborhoodVertices[g,i]
gives vertices that can be reached from vertex i.
NeighborhoodVertices
NeighborhoodVertices[g,i,r]
gives vertices that can be reached from vertex i within r hops.
NeighborhoodVertices[g,i]
gives vertices that can be reached from vertex i.
Details and Options
- NeighborhoodVertices functionality is now available in the built-in Wolfram Language function NeighborhoodGraph.
- To use NeighborhoodVertices, you first need to load the Graph Utilities Package using Needs["GraphUtilities`"].
- NeighborhoodVertices returns the vertices that can be reached from a given vertex within certain hops.
Examples
Basic Examples (2)
Needs["GraphUtilities`"]This defines a simple directed graph:
g = {1 -> 2, 2 -> 3, 1 -> 3, 2 -> 4, 4 -> 5, 5 -> 6, 6 -> 4};GraphPlot[g, VertexLabeling -> True, DirectedEdges -> True]This finds all vertices that can be reached from vertex 2 within 1 hop:
NeighborhoodVertices[g, 2, 1]This finds all vertices that can be reached from vertex 2:
NeighborhoodVertices[g, 2]NeighborhoodVertices has been superseded by NeighborhoodGraph:
g = Graph[{1 -> 2, 2 -> 3, 1 -> 3, 2 -> 4, 4 -> 5, 5 -> 6, 6 -> 4}]VertexList[NeighborhoodGraph[g, 2, 1, DirectedEdges -> True]]VertexList[NeighborhoodGraph[g, 2, DirectedEdges -> True]]Tech Notes
Related Guides
-
▪
- Graph Utilities Package ▪
- Graphs & Networks ▪
- Graph Visualization ▪
- Computation on Graphs ▪
- Graph Construction & Representation ▪
- Graphs and Matrices ▪
- Graph Properties & Measurements ▪
- Graph Operations and Modifications ▪
- Statistical Analysis ▪
- Social Network Analysis ▪
- Graph Properties ▪
- Mathematical Data Formats ▪
- Discrete Mathematics
Text
Wolfram Research (2007), NeighborhoodVertices, Wolfram Language function, https://reference.wolfram.com/language/GraphUtilities/ref/NeighborhoodVertices.html.
CMS
Wolfram Language. 2007. "NeighborhoodVertices." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/GraphUtilities/ref/NeighborhoodVertices.html.
APA
Wolfram Language. (2007). NeighborhoodVertices. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/GraphUtilities/ref/NeighborhoodVertices.html
BibTeX
@misc{reference.wolfram_2026_neighborhoodvertices, author="Wolfram Research", title="{NeighborhoodVertices}", year="2007", howpublished="\url{https://reference.wolfram.com/language/GraphUtilities/ref/NeighborhoodVertices.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_neighborhoodvertices, organization={Wolfram Research}, title={NeighborhoodVertices}, year={2007}, url={https://reference.wolfram.com/language/GraphUtilities/ref/NeighborhoodVertices.html}, note=[Accessed: 13-June-2026]}