This is documentation for Mathematica 7, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

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.
  • NeighborhoodVertices returns the vertices that can be reached from a given vertex within certain hops.
This defines a simple directed graph:
This finds all vertices that can be reached from vertex 2 within 1 hop:
This finds all vertices that can be reached from vertex 2:
Needs["GraphUtilities`"]
This defines a simple directed graph:
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
This finds all vertices that can be reached from vertex 2 within 1 hop:
In[4]:=
Click for copyable input
Out[4]=
This finds all vertices that can be reached from vertex 2:
In[5]:=
Click for copyable input
Out[5]=
This imports a sparse matrix, and finds a layout of the vertices:
This shows all vertices of hope 1, 2, 3 from vertex 1: