algebraic-graphs-0.6: A library for algebraic graph construction and transformation
Copyright(c) Andrey Mokhov 2016-2021
LicenseMIT (see the file LICENSE)
Maintainerandrey.mokhov@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Algebra.Graph.Relation.Transitive

Description

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

Synopsis

Data structure

data TransitiveRelation a Source #

The TransitiveRelation data type represents a transitive binary relation over a set of elements. Transitive relations satisfy all laws of the Transitive type class and, in particular, the closure axiom:

y /= empty ==> x * y + x * z + y * z == x * y + y * z

For example, the following holds:

path xs == (clique xs :: TransitiveRelation Int)

The Show instance produces transitively closed expressions:

show (1 * 2         :: TransitiveRelation Int) == "edge 1 2"
show (1 * 2 + 2 * 3 :: TransitiveRelation Int) == "edges [(1,2),(1,3),(2,3)]"

Instances

Instances details
Ord a => Eq (TransitiveRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.Transitive

(Ord a, Num a) => Num (TransitiveRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.Transitive

Ord a => Ord (TransitiveRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.Transitive

(Ord a, Show a) => Show (TransitiveRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.Transitive

IsString a => IsString (TransitiveRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.Transitive

NFData a => NFData (TransitiveRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.Transitive

Methods

rnf :: TransitiveRelation a -> () #

Ord a => Transitive (TransitiveRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.Transitive

Ord a => Graph (TransitiveRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.Transitive

Associated Types

type Vertex (TransitiveRelation a) Source #

type Vertex (TransitiveRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.Transitive

fromRelation :: Relation a -> TransitiveRelation a Source #

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

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

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