# Graph types

All graphs which can be used with the sampling algorithms belong to a type hierarchy. At the top of the hierarchy, there is `AbstractGraph`

:

`RRRMC.Interface.AbstractGraph`

— Type`AbstractGraph{ET<:Real}`

An abstract type representing an Ising spin model. The `ET`

parameter is the type returned by the `energy`

and `delta_energy`

functions.

See also `SimpleGraph`

, `DiscrGraph`

, `SingleGraph`

and `DoubleGraph`

.

There are currently three abstract subclasses and an alias, which determine how the sampling algorithms can be used:

`RRRMC.Interface.SimpleGraph`

— Type`SimpleGraph{ET} <: AbstractGraph{ET}`

An abstract type representing a generic graph.

The `ET`

parameter is the type returned by `energy`

and `delta_energy`

.

`RRRMC.Interface.DiscrGraph`

— Type`DiscrGraph{ET} <: AbstractGraph{ET}`

An abstract type representing a graph in which the `delta_energy`

values produced when flipping a spin belong to a finite discrete set, and thus can be sampled more efficiently with `rrrMC`

or `bklMC`

if the set is small.

The `ET`

parameter is the type returned by `energy`

and `delta_energy`

.

See also `allΔE`

.

`RRRMC.Interface.SingleGraph`

— Constant`SingleGraph{ET}`

A type alias representing either a `SimpleGraph`

or a `DiscrGraph{ET}`

. See also `DoubleGraph`

.

`RRRMC.Interface.DoubleGraph`

— Type`DoubleGraph{GT<:SingleGraph,ET} <: AbstractGraph{ET}`

An abstract type representing a graph in which the energy is the sum of two contributions, one of which is encoded in a graph of type `GT`

(see `SingleGraph`

). This allows `rrrMC`

to sample values more efficiently.

The `ET`

parameter is the type returned by the `energy`

and `delta_energy`

functions. Note that it can be different from the energy type of the internal `GT`

object (e.g., one can have a `DoubleGraph{DiscrGraph{Int},Float64}`

object).

*Note:* When you declare a type as subtype of this, `GT`

should *not* be the concrete type of the inner graph, but either `SimpleGraph{T}`

or `DiscrGraph{T}`

for some `T`

.

See also `inner_graph`

, `delta_energy_residual`

and `update_cache_residual!`

.