This is an example from the writeup of the EdgeIdeals package in the Journal of Software for Algebra and Geometry: Macaulay 2.
At the heart of the EdgeIdeals package are two new classes that are entitled HyperGraph and Graph. The HyperGraph class can only be used to represent hypergraphs. The class Graph extends from HyperGraph and inherits all of the methods of HyperGraph. Functions have been made that accept objects of either type as input.
In our example below, we illustrate Theorem 6.4.7 from R. Villarreal's Monomial Algebras, which says that the independence complex of a CohenMacaulay bipartite graph has a simplicial shelling. We begin by creating a graph and verifying the CohenMacaulay and bipartite properties.



When defining a (hyper)graph, the user specifies the vertex set by defining a polynomial ring, while the edges are written as a list of squarefree monomials (there are alternative ways of listing the edges). A (hyper)graph is stored as a hash table which contains the list of edges, the polynomial ring, and the list of vertices.



A CohenMacaulay bipartite graph must contain a leaf, which we retrieve above. We remove the leaf, to form the induced graph, and at the same time, we identify the vertex of degree one in the leaf.


Above, we formed the independence complex of H, that is, the simplicial complex whose facets correspond to the maximal independent sets of H. We then change the type from a simplicial complex to a hypergraph, which we call K. Notice that these edges give a shelling.





Using the method found in the proof of Theorem 6.4.7 from R. Villarreal's Monomial Algebras, we now can form a shelling of the original independence complex. Notice that our shelling is a permutation of the facets of the independence complex defined from G.