crem-0.1.0.0: Compositional representable executable machines
Safe HaskellSafe-Inferred
LanguageGHC2021

Crem.Graph

Description

A simple data structure to describe a directed graph

Synopsis

Graph

newtype Graph a Source #

A graph is just a list of edges between vertices of type a

Constructors

Graph [(a, a)] 

Instances

Instances details
Show a => Show (Graph a) Source # 
Instance details

Defined in Crem.Graph

Methods

showsPrec :: Int -> Graph a -> ShowS #

show :: Graph a -> String #

showList :: [Graph a] -> ShowS #

Eq a => Eq (Graph a) Source # 
Instance details

Defined in Crem.Graph

Methods

(==) :: Graph a -> Graph a -> Bool #

(/=) :: Graph a -> Graph a -> Bool #

productGraph :: Graph a -> Graph b -> Graph (a, b) Source #

The product graph. It has as vertices the product of the set of vertices of the initial graph. It has as edge from (a1, b1) to (a2, b2) if and only if there is an edge from a1 to a2 and an edge from b1 to b2

>>> productGraph (Graph [('a', 'b')]) (Graph [('c', 'd')])
Graph [(('a','c'),('b','d'))]

transitiveClosureGraph :: Eq a => Graph a -> Graph a Source #

Computes all the possible paths in the input graph and considers them as edges. Notice that the current implementation is removing duplicates

addIdentityEdges :: RenderableVertices a => Graph a -> Graph a Source #

Add all the identity edges to a graph

removeIdentityEdges :: Eq a => Graph a -> Graph a Source #

Remove all the edges which start and end at the same vertex

UntypedGraph

data UntypedGraph Source #

A data type to represent a graph which is not tracking the vertex type

Constructors

forall a.(RenderableVertices a, Eq a, Show a) => UntypedGraph (Graph a) 

Instances

Instances details
Show UntypedGraph Source # 
Instance details

Defined in Crem.Graph

untypedProductGraph :: UntypedGraph -> UntypedGraph -> UntypedGraph Source #

Same as productGraph but for UntypedGraph

untypedTransitiveClosureGraph :: UntypedGraph -> UntypedGraph Source #

Same as transitiveClosureGraph but for UntypedGraph

untypedAddIdentityEdges :: UntypedGraph -> UntypedGraph Source #

Add all identity edges to an UntypedGraph

untypedRemoveIdentityEdges :: UntypedGraph -> UntypedGraph Source #

Remove all the edges which start and end at the same vertex from an UntypedGraph