HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulefgl-arbitrary-0.2.0.6Haskell2010

Data.Graph.Inductive.Arbitrary

This module provides default definitions for use with QuickCheck's Arbitrary class.

Both Data.Graph.Inductive.Tree- and Data.Graph.Inductive.PatriciaTree-based graph implementations have Arbitrary instances. In most cases, this is all you will need.

If, however, you want to create arbitrary custom graph-like data structures, then you will probably want to do some custom processing from an arbitrary GraphNodesEdges value, either directly or with a custom ArbGraph instance.

  • 7 types
  • 1 class
  • 9 values

Explicit graph creation

4 declarations

If you wish to explicitly create a generated graph value (rather than using the Arbitrary class) then you will want to use these functions.

valueshrinkGraph :: Graph gr => gr a b -> [gr a b]
#

For a graph with at least two nodes, return every possible way of deleting a single node (i.e. will never shrink to an empty graph).

Types of graphs

4 declarations
classclass DynGraph (BaseGraph ag) => ArbGraph (ag :: Type -> Type -> Type) where
#

Representation of generating arbitrary graph structures.

Typically, you would only use this for the toBaseGraph function or if you wanted to make a custom graph wrapper.

The intent of this class is to simplify defining and using different wrappers on top of graphs (e.g. you may wish to have an Undirected graph, or one with NoLoops, or possibly both!).

Associated types

Methods

Instances5ArbGraph
datadata GrProxy (gr :: Type -> Type -> Type)
#

A simple graph-specific proxy type.

Instances4Eq, Ord, Read, Show
  • Eq (GrProxy gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary
  • Ord (GrProxy gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary
  • Read (GrProxy gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary
  • Show (GrProxy gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary

Specific graph structures

newtypenewtype NoMultipleEdges (gr :: Type -> Type -> Type) a b
#

A newtype wrapper to generate a graph without multiple edges (loops allowed).

Constructors

Instances6ArbGraph, Eq, Read, Show, Arbitrary, BaseGraph
newtypenewtype NoLoops (gr :: Type -> Type -> Type) a b
#

A newtype wrapper to generate a graph without loops (multiple edges allowed).

Constructors

Instances6ArbGraph, Eq, Read, Show, Arbitrary, BaseGraph
newtypenewtype Undirected (gr :: Type -> Type -> Type) a b
#

A newtype wrapper such that each (non-loop) edge also has its reverse in the graph.

Note that there is no way to guarantee this after any additional edges are added or removed.

You should also apply this wrapper after NoMultipleEdges or else the wrong reverse edge might be removed.

Constructors

Instances6ArbGraph, Eq, Read, Show, Arbitrary, BaseGraph

Connected graphs

datadata Connected (ag :: Type -> Type -> Type) a b
#

A brute-force approach to generating connected graphs.

The resultant graph (obtained with connGraph) will never be empty: it will, at the very least, contain an additional connected node (obtained with connNode).

Note that this is not an instance of ArbGraph as it is not possible to arbitrarily layer a transformer on top of this.

Constructors

Instances4Eq, Read, Show, Arbitrary

Node and edge lists

3 declarations
datadata GraphNodesEdges a b
#

Defined so as to be able to generate valid arbitrary node and edge lists.

If any specific structure (no multiple edges, no loops, etc.) is required then you will need to post-process this after generating it, or else create a new instance of ArbGraph.

Constructors

Instances5Eq, Ord, Read, Show, Arbitrary

Orphan instances

2 instances