Copyright | (c) Andrey Mokhov 2016-2022 |
---|---|
License | MIT (see the file LICENSE) |
Maintainer | andrey.mokhov@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
An abstract implementation of reflexive binary relations. Use Algebra.Graph.Class for polymorphic construction and manipulation.
Synopsis
- data ReflexiveRelation a
- fromRelation :: Relation a -> ReflexiveRelation a
- toRelation :: Ord a => ReflexiveRelation a -> Relation a
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)]"
Instances
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.