# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Compute toppling trajectories of Abelian sandpiles on undirected finite multigraphs

Contributed by:
Phileas Dazeley-Gaist

ResourceFunction["SandpileTopple"][ returns the sandpile | |

ResourceFunction["SandpileTopple"][ returns the sandpile | |

ResourceFunction["SandpileTopple"][ returns a list of the results of toppling | |

ResourceFunction["SandpileTopple"][ iteratively topple | |

ResourceFunction["SandpileTopple"][ returns a list of the results of toppling | |

ResourceFunction["SandpileTopple"][ iteratively topple | |

ResourceFunction["SandpileTopple"][ returns a list of the results of toppling |

SandpileTopple topples every unstable vertex of the sandpile graph *g *once at each *toppling step*.

A *sandpile graph* is a multigraph with zero-weighted or positively weighted vertices, and exactly one *sink* vertex, weighted *“sink”*. For the purposes of this function, sandpile graphs are assumed to be undirected. In a sandpile graph, vertices are points in space. Vertex weights represent amounts of sand at each of these points, and edges form the connections that allow sand to move from one vertex to another. Sandpile graph vertex weights are typically integers, which one can interpret as grains of sand, but can also be positive real numbers, analogous to continuous quantities of sand.

When the weight of a sandpile vertex is greater than or equal to its degree, the vertex is *unstable*, and will *topple* at the next toppling step. As it topples, it sends 1 to each of its adjacent vertices, except for the sink vertex, and loses the value of its degree from its weight. A *sandpile *vertex is stable if its weight is less than its degree. Stable vertices do not topple. The sink vertex does not participate in the toppling process.

A sandpile in which the sink is not connected to any of the vertices is a valid sandpile, but it is not guaranteed to ever reach a fixed point through iterated toppling. When the sink is connected to at least one non-sink vertex, iterated toppling will always yield a fixed point given enough iterations.

Use the "DeleteSink" option to remove the sink vertex from computed toppled graphs.

By default, SandpileTopple styles vertices according to their weight. Use ColorFunction to control the vertex colouring scheme.

To disable styling, set "StyleSandpile" to False. Doing so will save computational resources when computing long toppling sequences, toppling large graphs.

Topple a sandpile once:

In[1]:= |

Out[1]= |

Topple a sandpile thrice:

In[2]:= |

Out[2]= |

Topple a sandpile four times and return the complete list of toppling steps:

In[3]:= |

Out[3]= |

Topple a sandpile until results no longer change:

In[4]:= |

Out[4]= |

Topple a sandpile until results no longer change, and return the complete list of toppling steps:

In[5]:= |

Out[5]= |

Find the fixed point of a sandpile toppling trajectory in at most *n=5* toppling steps:

In[6]:= |

Out[6]= |

Compute the fixed point of the toppling trajectory of an Abelian sandpile on a rectangular grid:

In[7]:= |

Out[7]= |

Compute the fixed point of the toppling trajectory on a triangular grid:

In[8]:= |

Out[8]= |

Compute the fixed point of the toppling trajectory on a hexagonal grid:

In[9]:= |

Out[9]= |

Compute the fixed point of the toppling trajectory of an Abelian sandpile on a Sierpiński gasket graph:

In[10]:= |

Out[10]= |

Compute the fixed point of the toppling trajectory of an Abelian sandpile on a Sierpiński Carpet:

In[11]:= |

Out[11]= |

Compute steps of a toppling trajectory on a 3-ary tree:

In[12]:= |

Out[12]= |

Define a function to configure a graph sandpile's boundary conditions by connecting boundary vertices to a sink vertex.

The function below takes the following three arguments: *g*, the graph to be configured, a list *sinkConnections* of *vertex→number* rules specifying the number of connections to the sink for each sink-connected vertex, and *sink*, which specifies the sink vertex, and defaults to 0:

In[13]:= |

Configure a valid sandpile by adding and connecting a sink vertex to a graph:

In[14]:= |

Out[14]= |

Use an existing vertex as the sink:

In[15]:= |

Out[15]= |

When "StyleSandpile" is set to True, set the vertex color scheme using the ColorFunction option:

In[16]:= |

Out[16]= |

To delete the sink vertex from computed toppled sandpiles, set the "DeleteSink" option to True:

In[17]:= |

Out[17]= |

By default, SandpileTopple will style toppled sandpiles so that the vertices are colored by their weights. To disable this behavior and preserve the styling of the initial sandpile, set the "StyleSandpile" option to False:

In[18]:= |

Out[18]= |

The behaviour of the VertexShape option is modified so as to preserve vertex colors when the shape is specified as a single Graphics object:

In[19]:= |

Out[19]= |

SandpileTopple may not terminate if the sink vertex of the provided sandpile is not connected to at least one non-sink vertex:

In[21]:= |

Out[21]= |

Animate a toppling trajectory on a fully unstable scale-free graph sandpile:

In[22]:= |

Out[22]= |

Topple arbitrary mesh graphs such as this grounded triceratops:

In[23]:= |

Out[24]= |

In[25]:= |

Out[25]= |

- An Elementary Introduction to the Wolfram Language: Graphs and Networks
- Wolfram Documentation: Graph Construction and Representation

Wolfram Language 13.0 (December 2021) or above

- 1.0.0 – 05 February 2024

This work is licensed under a Creative Commons Attribution 4.0 International License