Copyright | (c) Andrey Mokhov 2016-2018 |
---|---|
License | MIT (see the file LICENSE) |
Maintainer | andrey.mokhov@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Alga is a library for algebraic construction and manipulation of graphs in Haskell. See this paper for the motivation behind the library, the underlying theory, and implementation details.
This module provides a minimal and experimental implementation of algebraic graphs with edge labels. The API will be expanded in the next release.
Synopsis
- data Graph e a
- type UnlabelledGraph a = Graph Bool a
- empty :: Graph e a
- vertex :: a -> Graph e a
- edge :: Dioid e => a -> a -> Graph e a
- overlay :: Semilattice e => Graph e a -> Graph e a -> Graph e a
- connect :: Dioid e => Graph e a -> Graph e a -> Graph e a
- connectBy :: e -> Graph e a -> Graph e a -> Graph e a
- (-<) :: Graph e a -> e -> (Graph e a, e)
- (>-) :: (Graph e a, e) -> Graph e a -> Graph e a
- edgeLabel :: (Eq a, Semilattice e) => a -> a -> Graph e a -> e
Algebraic data type for edge-labeleld graphs
Edge-labelled graphs, where the type variable e
stands for edge labels.
For example, Graph Bool a
is isomorphic to unlabelled graphs defined in
the top-level module Algebra.Graph.Graph, where False
and True
denote
the lack of and the existence of an unlabelled edge, respectively.
Instances
Functor (Graph e) Source # | |
Foldable (Graph e) Source # | |
Defined in Algebra.Graph.Labelled fold :: Monoid m => Graph e m -> m # foldMap :: Monoid m => (a -> m) -> Graph e a -> m # foldr :: (a -> b -> b) -> b -> Graph e a -> b # foldr' :: (a -> b -> b) -> b -> Graph e a -> b # foldl :: (b -> a -> b) -> b -> Graph e a -> b # foldl' :: (b -> a -> b) -> b -> Graph e a -> b # foldr1 :: (a -> a -> a) -> Graph e a -> a # foldl1 :: (a -> a -> a) -> Graph e a -> a # elem :: Eq a => a -> Graph e a -> Bool # maximum :: Ord a => Graph e a -> a # minimum :: Ord a => Graph e a -> a # | |
Traversable (Graph e) Source # | |
(Show a, Show e) => Show (Graph e a) Source # | |
Dioid e => Graph (Graph e a) Source # | |
type Vertex (Graph e a) Source # | |
Defined in Algebra.Graph.Labelled |
type UnlabelledGraph a = Graph Bool a Source #
A type synonym for unlabelled graphs.
Construct the empty graph. An alias for the constructor Empty
.
Complexity: O(1) time, memory and size.
vertex :: a -> Graph e a Source #
Construct the graph comprising a single isolated vertex. An alias for the
constructor Vertex
.
Complexity: O(1) time, memory and size.
edge :: Dioid e => a -> a -> Graph e a Source #
Construct the graph comprising a single edge with the label one
.
Complexity: O(1) time, memory and size.
connect :: Dioid e => Graph e a -> Graph e a -> Graph e a Source #
Connect two graphs. An alias for Connect
one
. This is an associative
operation with the identity empty
, which distributes over overlay
and
obeys the decomposition axiom. See the full list of laws in Algebra.Graph.
Complexity: O(1) time and memory, O(s1 + s2) size. Note that the number
of edges in the resulting graph is quadratic with respect to the number of
vertices of the arguments: m = O(m1 + m2 + n1 * n2).
connectBy :: e -> Graph e a -> Graph e a -> Graph e a Source #
Connect two graphs with edges labelled by a given label. An alias for
Connect
.
Complexity: O(1) time and memory, O(s1 + s2) size. Note that the number
of edges in the resulting graph is quadratic with respect to the number of
vertices of the arguments: m = O(m1 + m2 + n1 * n2).