NeighborhoodVertices

As of Version 10, all the functionality of the GraphUtilities package is built into the Wolfram System. >>

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.

DetailsDetails

  • 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.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

In[1]:=
Click for copyable input

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]=

NeighborhoodVertices has been superseded by NeighborhoodGraph:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=