algebraic-graphs-0.0.4: A library for algebraic graph construction and transformation

Copyright(c) Andrey Mokhov 2016-2017
LicenseMIT (see the file LICENSE)
Maintainerandrey.mokhov@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Algebra.Graph.Relation.Reflexive

Contents

Description

An abstract implementation of reflexive binary relations. Use Algebra.Graph.Class for polymorphic construction and manipulation.

Synopsis

Data structure

data ReflexiveRelation a Source #

The ReflexiveRelation data type represents a reflexive binary relation over a set of elements. Reflexive relations satisfy all laws of the Reflexive type class and, in particular, the self-loop axiom:

vertex x == vertex x * vertex x

The Show instance produces reflexively closed expressions:

show (1     :: ReflexiveRelation Int) == "edge 1 1"
show (1 * 2 :: ReflexiveRelation Int) == "edges [(1,1),(1,2),(2,2)]"

fromRelation :: Relation a -> ReflexiveRelation a Source #

Construct a reflexive relation from a Relation. Complexity: O(1) time.

toRelation :: Ord a => ReflexiveRelation a -> Relation a Source #

Extract the underlying relation. Complexity: O(n*log(m)) time.