fgl-arbitrary-0.1.0.0: QuickCheck support for fgl

Copyright(c) Ivan Lazar Miljenovic
LicenseBSD3
MaintainerIvan.Miljenovic@gmail.com
Safe HaskellNone
LanguageHaskell2010

Data.Graph.Inductive.Arbitrary

Contents

Description

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

Synopsis

Documentation

arbitraryGraph :: (Graph gr, Arbitrary a, Arbitrary b) => Gen (gr a b) Source

Generate an arbitrary graph. Multiple edges are allowed.

arbitraryGraphWith :: (Graph gr, Arbitrary a, Arbitrary b) => ([LEdge b] -> [LEdge b]) -> Gen (gr a b) Source

Generate an arbitrary graph, using the specified function to manipulate the generated list of edges (e.g. remove multiple edges).

shrinkGraph :: Graph gr => gr a b -> [gr a b] Source

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).

shrinkGraphWith :: Graph gr => gr a b -> [(Node, gr a b)] Source

Types of graphs

class DynGraph (BaseGraph ag) => ArbGraph ag where Source

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.

Associated Types

type BaseGraph ag :: * -> * -> * Source

Methods

toBaseGraph :: ag a b -> BaseGraph ag a b Source

fromBaseGraph :: BaseGraph ag a b -> ag a b Source

edgeF :: Proxy ag -> [LEdge b] -> [LEdge b] Source

Any manipulation of edges that should be done to satisfy the requirements of the specified wrapper.

shrinkFWith :: ag a b -> [(Node, ag a b)] Source

Shrinking function (assuming only one node is removed at a time) which also returns the node that is removed.

shrinkF :: ArbGraph ag => ag a b -> [ag a b] Source

arbitraryGraphBy :: forall ag a b. (ArbGraph ag, Arbitrary a, Arbitrary b) => Gen (ag a b) Source

Generate an instance of ArbGraph using the class methods.

Specific graph structures

newtype NoMultipleEdges gr a b Source

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

Constructors

NME 

Fields

nmeGraph :: gr a b
 

Instances

ArbGraph gr => ArbGraph (NoMultipleEdges gr) Source 
Eq (gr a b) => Eq (NoMultipleEdges gr a b) Source 
Read (gr a b) => Read (NoMultipleEdges gr a b) Source 
Show (gr a b) => Show (NoMultipleEdges gr a b) Source 
(ArbGraph gr, Arbitrary a, Arbitrary b) => Arbitrary (NoMultipleEdges gr a b) Source 
type BaseGraph (NoMultipleEdges gr) = BaseGraph gr Source 

newtype NoLoops gr a b Source

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

Constructors

NL 

Fields

looplessGraph :: gr a b
 

Instances

ArbGraph gr => ArbGraph (NoLoops gr) Source 
Eq (gr a b) => Eq (NoLoops gr a b) Source 
Read (gr a b) => Read (NoLoops gr a b) Source 
Show (gr a b) => Show (NoLoops gr a b) Source 
(ArbGraph gr, Arbitrary a, Arbitrary b) => Arbitrary (NoLoops gr a b) Source 
type BaseGraph (NoLoops gr) = BaseGraph gr Source 

type SimpleGraph gr a b = NoLoops (NoMultipleEdges gr) a b Source

A wrapper to generate a graph without multiple edges and no loops.

newtype Undirected gr a b Source

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

UG 

Fields

undirGraph :: gr a b
 

Instances

ArbGraph gr => ArbGraph (Undirected gr) Source 
Eq (gr a b) => Eq (Undirected gr a b) Source 
Read (gr a b) => Read (Undirected gr a b) Source 
Show (gr a b) => Show (Undirected gr a b) Source 
(ArbGraph gr, Arbitrary a, Arbitrary b) => Arbitrary (Undirected gr a b) Source 
type BaseGraph (Undirected gr) = BaseGraph gr Source 

Connected graphs

data Connected ag a b Source

A brute-force approach to generating connected graphs.

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

Instances

(Eq a, Eq b, Eq (ag a b)) => Eq (Connected ag a b) Source 
(Read a, Read b, Read (ag a b)) => Read (Connected ag a b) Source 
(Show a, Show b, Show (ag a b)) => Show (Connected ag a b) Source 
(ArbGraph ag, Arbitrary a, Arbitrary b) => Arbitrary (Connected ag a b) Source 

connGraph :: ArbGraph ag => Connected ag a b -> BaseGraph ag a b Source

Node and edge lists

arbitraryNodes :: Arbitrary a => Gen [LNode a] Source

Generally a list of labelled nodes.

arbitraryEdges :: Arbitrary b => [LNode a] -> Gen [LEdge b] Source

Given a specified list of nodes, generate a list of edges.

data GraphNodesEdges a b Source

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.

Constructors

GNEs 

Fields

graphNodes :: [LNode a]
 
graphEdges :: [LEdge b]
 

Instances