NeighborhoodGraph

NeighborhoodGraph[g,v]

gives the graph neighborhood of a vertex v in the graph g.

NeighborhoodGraph[g,{a1,a2,}]

gives the graph neighborhood of the ai that can be vertices, edges, or subgraphs of g.

NeighborhoodGraph[g,patt]

gives the graph neighborhood of the vertices and edges that match the pattern patt.

NeighborhoodGraph[g,,d]

gives the neighborhood up to distance d.

NeighborhoodGraph[{vw,},]

uses rules vw to specify the graph g.

Details and Options

  • The neighborhood graph for a vertex v is given by vertices adjacent to v and the edges connecting them.
  • The neighborhood graph for an edge e is the neighborhood graph for the vertices of e.
  • The neighborhood graph for a subgraph h is the neighborhood graph for the vertices in h.
  • The neighborhood graph at distance d is the neighborhood graph for the vertices of the neighborhood graph at distance d-1.
  • The default value for d is 1.
  • NeighborhoodGraph works with undirected graphs, directed graphs, multigraphs, and mixed graphs.

Examples

open allclose all

Basic Examples  (2)

Give the neighborhood from vertex 1 in a graph:

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

From a set of vertices:

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

Give the neighborhood up to distance k from the vertices:

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

Scope  (8)

Applications  (2)

Properties & Relations  (2)

Neat Examples  (2)

See Also

Graph  Subgraph  AdjacencyList  IncidenceList

Introduced in 2010
(8.0)
| Updated in 2015
(10.3)