Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Find the volumes of successively larger neighborhoods around nodes in a graph
ResourceFunction["GraphNeighborhoodVolumes"][graph] gives the numbers of neighbors within successive distances for each vertex in graph. | |
ResourceFunction["GraphNeighborhoodVolumes"][graph,{v1,v2,…}] finds the numbers for the vertices vi. | |
ResourceFunction["GraphNeighborhoodVolumes"][graph,All,r] finds the numbers of neighbors for all vertices out to maximum radius r. | |
ResourceFunction["GraphNeighborhoodVolumes"][graph,vi,Automatic] finds the numbers of neighbors only out to the minimum radius for any of the vertices vi. | |
ResourceFunction["GraphNeighborhoodVolumes"][graph,"Random"→n,…] finds the numbers of neighbors for n randomly chosen vertices. |
In a complete graph, the volume around each node includes every node after one step:
In[1]:= |
![]() |
Out[1]= |
![]() |
In this graph, the volume grows linearly with the radius:
In[2]:= |
![]() |
Out[2]= |
![]() |
Limit to distance 2:
In[3]:= |
![]() |
Out[3]= |
![]() |
In this graph, the volume basically grows exponentially with the radius:
In[4]:= |
![]() |
Out[4]= |
![]() |
Demonstrating the padded volume of the same graph:
In[5]:= |
![]() |
Out[5]= |
![]() |
The padded volume can also be taken for an integer less than the maximum graph radius:
In[6]:= |
![]() |
Out[6]= |
![]() |
Find the numbers of neighbors starting from node 20:
In[7]:= |
![]() |
Out[7]= |
![]() |
Find the average volumes of successively larger balls around every vertex:
In[8]:= |
![]() |
Out[8]= |
![]() |
Plot the result:
In[9]:= |
![]() |
Out[9]= |
![]() |
Find the average padded volumes of successively larger balls around every vertex:
In[10]:= |
![]() |
Out[10]= |
![]() |
In[11]:= |
![]() |
Out[11]= |
![]() |
Converting the undirected graph from the previous example into a graph with asymmetric edges illustrates how padding helps:
In[12]:= |
![]() |
Out[12]= |
![]() |
Taking the padded graph neighborhood volumes bypasses the limitations in calculating volume that are imposed by vertices in directed graphs that have small radii:
In[13]:= |
![]() |
Out[13]= |
![]() |
In[14]:= |
![]() |
Out[14]= |
![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License