此为 Mathematica 7 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.2)

NeighborhoodSubgraph

NeighborhoodSubgraph[g, i, r]
gives a subgraph consists of vertices that can be reached from vertex i within r hops.
NeighborhoodSubgraph[g, i]
gives a subgraph consists of vertices that can be reached from vertex i.
  • NeighborhoodSubgraph returns a subgraph consists of vertices that can be reached from a given vertex within certain hops.
Needs["GraphUtilities`"]
This defines a simple directed graph:
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
In[4]:=
Click for copyable input
Out[4]=
This finds a subgraph from vertices that can be reached from vertex 2 within 3 hop:
In[5]:=
Click for copyable input
Out[5]=
In[6]:=
Click for copyable input
Out[6]=
This finds a subgraph consists of all vertices that can be reached from vertex 2:
In[7]:=
Click for copyable input
Out[7]=
In[8]:=
Click for copyable input
Out[8]=