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

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

Algebra.Graph.Relation.Symmetric

Contents

Description

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

Synopsis

Data structure

data SymmetricRelation a Source #

The SymmetricRelation data type represents a symmetric binary relation over a set of elements. Symmetric relations satisfy all laws of the Undirected type class and, in particular, the commutativity of connect:

connect x y == connect y x

The Show instance produces symmetrically closed expressions:

show (1     :: SymmetricRelation Int) == "vertex 1"
show (1 * 2 :: SymmetricRelation Int) == "edges [(1,2),(2,1)]"
Instances
Ord a => Eq (SymmetricRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.InternalDerived

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

Defined in Algebra.Graph.Relation.InternalDerived

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

Defined in Algebra.Graph.Relation.InternalDerived

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

Defined in Algebra.Graph.Relation.InternalDerived

Methods

rnf :: SymmetricRelation a -> () #

Ord a => Undirected (SymmetricRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.InternalDerived

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

Defined in Algebra.Graph.Relation.InternalDerived

Associated Types

type Vertex (SymmetricRelation a) :: Type Source #

type Vertex (SymmetricRelation a) Source # 
Instance details

Defined in Algebra.Graph.Relation.InternalDerived

fromRelation :: Relation a -> SymmetricRelation a Source #

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

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

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

Graph properties

neighbours :: Ord a => a -> SymmetricRelation a -> Set a Source #

The set of neighbours of an element x is the set of elements that are related to it, i.e. neighbours x == { a | aRx }. In the context of undirected graphs, this corresponds to the set of adjacent vertices of vertex x.

neighbours x empty      == Set.empty
neighbours x (vertex x) == Set.empty
neighbours x (edge x y) == Set.fromList [y]
neighbours y (edge x y) == Set.fromList [x]