The following is separated into four sections:
The main way of constructing Graph and HyperGraph objects is to use the graph and hyperGraph methods. These methods are overridden to provide many ways of specifying edges.
For the purposes of the EdgeIdeals package, every graph and hypergraph is associated to a ring whose variables correspond to the vertices of the (hyper)graph. Thus, the most explicit way to make a graph or hypergraph is by graph(PolynomialRing,List) and hyperGraph(PolynomialRing,List).The list parameter must contain edges which themselves are lists of variables in the ring.



Probably the most convenient way of specifying edges is as a list of monomials. Using the graph(List) and hyperGraph(List) methods implicitly defines the ring of the (hyper)graph to be the ring containing the monomials in the List. The following example gives the same hypergraphs as before.



The graph and hyperGraph constructors can also be used to make (hyper)graphs from squarefree monomial ideals.The minimal generators of the ideal become the edges of the (hyper)graph. The ideal must be generated by quadratics if the graph constructor is used.

In this section, we will see how to convert between SimplicialComplexes and HyperGraphs, as well as between Graphs and HyperGraphs.
The methods simplicialComplexToHyperGraph and hyperGraphToSimplicialComplex accomplish the former conversion in the following way. In simplicialComplexToHyperGraph facets of the simplicial complex become the edges of the hypergraph, while in hyperGraphToSimplicialComplex the edges of the hypergraph become the facets of the new simplicial complex.




The conversion of a graph into a hypergraph and vice versa use the constructors graph and hyperGraph. Any graph can be converted to a hyperGraph, but when a hyperGraph is converted into a graph, a check is run to ensure that the edges are all of size two. An error will be produced if this is not the case.




Since the Graph type is a subclass of HyperGraph, any method that takes a HyperGraph will also work on Graphs. So the conversion from graph to hypergraph is seldom needed; it is only needed when a method works differently on graphs than on hypergraphs (see complementGraph for an example).
On the other hand, the conversion from hypergraph to graph is very important as many methods are only defined on graphs. In the following example, we use the isChordal method which only applies to graphs and hence necessitates a conversion of types.





In addition to the more general constructors, there a number of methods which produce certain special graphs.
Cycles can be constructed using cycle which, depending on the parameters, uses all or some of the variables in the ring to define a graph cycle.




AntiCycles, the graph complements of cycles, can be constructed using antiCycle, which takes parameters similar to those of cycle.


Complete graphs can be constructed using completeGraph, which defines a graph with every possible edge between a given set a vertices.




Complete multipartite graphs can be constructed using completeMultiPartite, which defines a graph with every possible edge between certain partitions of the vertices. See completeMultiPartite for more details.


Three methods are provided for the construction of random (hyper)graphs.
Each method allows you to specify the number of edges desired. For the random hypergraph methods, the sizes of the edges must also be specified.




The randomHyperGraph method is not guaranteed to return a hypergraph; sometimes it returns null. Please see the documentation of this method for more details.