# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Partition the vertices of a directed acyclic graph into time-ordered level sets

Contributed by:
Bradley Klee

ResourceFunction["VertexStratify"][ returns a minimal, time-ordered partitioning of the vertices of a directed acyclic graph | |

ResourceFunction["VertexStratify"][ returns a comprehensive set of stratifications, with at most | |

ResourceFunction["VertexStratify"][ introduces a cutoff |

A partitioning is minimal provided each vertex appears in the level immediately after the one with its last appearing component.

Every directed acyclic graph (DAG) has a set of vertices with VertexInDegree equal to zero, called "sources"; the sources of the DAG are listed in the base level (or stratum) of the minimal stratification.

Subsequent vertices are listed in the next stratum as soon as all of their inputs are included in preceding strata. Consequently, directed edges always point from an earlier stratum to a later one.

There is an equally minimal reverse stratification obtained by applying time reversal to the input graph. Vertices with VertexOutDegree equal zero (called “sinks”) then form the base stratum. Subsequent strata membership is determined treating sinks as sources and moving reversely along directed edges.

If the forward and reverse stratifications are identical, the graph is said to be *stratification-rigid*.

Every graph contains a stratification-rigid subgraph, which determines a stratification axis and a minimal length thereof.

If the graph is not entirely stratification-rigid, alternative stratifications can be obtained by perturbing "loose" vertices forward along the stratification axis.

Since the stratification axis has a fixed length, the number of possible stratifications must be finite.

The optional parameter *n* effectively lengthens the stratification axis, thus allowing enumeration of additional "extra-loose" stratifications.

Depending how large the non-stratification-rigid subgraph is, it may be necessary to introduce a cutoff *max* to force halting in reasonable time.

Create a randomly-labeled path graph:

In[1]:= |

Out[1]= |

Find the order of vertices:

In[2]:= |

Out[2]= |

Stratify vertices in a two-dimensional graph:

In[3]:= |

Out[3]= |

For a three-dimensional grid graph, count the number of vertices per level:

In[4]:= |

Out[4]= |

Plot a binary tree by using the stratification to determine vertex coordinates:

In[5]:= |

Out[5]= |

Arrange vertices of a RandomGraph along a horizontal time axis:

In[6]:= |

Out[6]= |

Color nodes of a grid graph according to their distance from a corner:

In[7]:= |

Out[7]= |

Plot a tree graph according to different vertex stratifications:

In[8]:= |

Out[8]= |

The output of GridGraph is rigid in the sense of having only one stratification of minimal length:

In[9]:= |

Out[9]= |

If the time axis is extended, more foliations can be obtained (cf. oeis.org/A002415):

In[10]:= |

Out[10]= |

If a graph is extremely non-rigid, a cutoff can be given to limit the number of results returned:

In[11]:= |

Out[11]= |

VertexStratify does not accept undirected graphs as inputs:

In[12]:= |

Out[12]= |

Highlight the stratification-rigid subgraph of a random graph:

In[13]:= |

Out[13]= |

- 1.1.0 – 07 November 2022
- 1.0.0 – 17 June 2022

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