Generate an arbitrary graph. Multiple edges are allowed.
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
- Packagefgl-arbitrary-0.2.0.6
- Exports17
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceArbitrary.hs
Explicit graph creation
4 declarationsIf you wish to explicitly create a generated graph value (rather than using the Arbitrary class) then you will want to use these functions.
Generate an arbitrary graph, using the specified function to manipulate the generated list of edges (e.g. remove multiple edges).
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).
As with shrinkGraph, but also return the node that was deleted.
Types of graphs
4 declarationsRepresentation 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!).
Methods
toBaseGraph :: ag a b -> BaseGraph ag a bfromBaseGraph :: BaseGraph ag a b -> ag a bedgeF :: GrProxy ag -> [LEdge b] -> [LEdge b]Any manipulation of edges that should be done to satisfy the requirements of the specified wrapper.
shrinkFWith :: ag a b -> [(Node, ag a b)]Shrinking function (assuming only one node is removed at a time) which also returns the node that is removed.
Instances5ArbGraph
ArbGraph GrDefined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryArbGraph GrDefined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryArbGraph gr => ArbGraph (NoLoops gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryArbGraph gr => ArbGraph (NoMultipleEdges gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryArbGraph gr => ArbGraph (Undirected gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary
A simple graph-specific proxy type.
Instances4Eq, Ord, Read, Show
Eq (GrProxy gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryOrd (GrProxy gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryRead (GrProxy gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryShow (GrProxy gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary
Generate an instance of ArbGraph using the class methods.
Specific graph structures
A newtype wrapper to generate a graph without multiple edges (loops allowed).
Instances6ArbGraph, Eq, Read, Show, Arbitrary, BaseGraph
ArbGraph gr => ArbGraph (NoMultipleEdges gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryEq (gr a b) => Eq (NoMultipleEdges gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryRead (gr a b) => Read (NoMultipleEdges gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryShow (gr a b) => Show (NoMultipleEdges gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary(ArbGraph gr, Arbitrary a, Arbitrary b) => Arbitrary (NoMultipleEdges gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrarytype BaseGraph (NoMultipleEdges gr) = BaseGraph grDefined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary
A newtype wrapper to generate a graph without loops (multiple edges allowed).
Constructors
NLlooplessGraph :: gr a b
Instances6ArbGraph, Eq, Read, Show, Arbitrary, BaseGraph
ArbGraph gr => ArbGraph (NoLoops gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryEq (gr a b) => Eq (NoLoops gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryRead (gr a b) => Read (NoLoops gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryShow (gr a b) => Show (NoLoops gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary(ArbGraph gr, Arbitrary a, Arbitrary b) => Arbitrary (NoLoops gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrarytype BaseGraph (NoLoops gr) = BaseGraph grDefined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary
A wrapper to generate a graph without multiple edges and no loops.
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
UGundirGraph :: gr a b
Instances6ArbGraph, Eq, Read, Show, Arbitrary, BaseGraph
ArbGraph gr => ArbGraph (Undirected gr)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryEq (gr a b) => Eq (Undirected gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryRead (gr a b) => Read (Undirected gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryShow (gr a b) => Show (Undirected gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary(ArbGraph gr, Arbitrary a, Arbitrary b) => Arbitrary (Undirected gr a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrarytype BaseGraph (Undirected gr) = BaseGraph grDefined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary
Connected graphs
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
CGconnNode :: NodeconnArbGraph :: ag a b
Instances4Eq, Read, Show, Arbitrary
Eq (ag a b) => Eq (Connected ag a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryRead (ag a b) => Read (Connected ag a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.ArbitraryShow (ag a b) => Show (Connected ag a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary(ArbGraph ag, Arbitrary a, Arbitrary b) => Arbitrary (Connected ag a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary
The underlying graph represented by this Connected value.
Node and edge lists
3 declarationsGenerally a list of labelled nodes.
Given a specified list of nodes, generate a list of edges.
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
GNEsgraphNodes :: [LNode a]graphEdges :: [LEdge b]
Instances5Eq, Ord, Read, Show, Arbitrary
(Eq a, Eq b) => Eq (GraphNodesEdges a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary(Ord a, Ord b) => Ord (GraphNodesEdges a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary(Read a, Read b) => Read (GraphNodesEdges a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary(Show a, Show b) => Show (GraphNodesEdges a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary(Arbitrary a, Arbitrary b) => Arbitrary (GraphNodesEdges a b)Defined in fgl-arbitrary-0.2.0.6 · Data.Graph.Inductive.Arbitrary