swish-0.10.4.0: A semantic web toolkit.

Copyright | (c) 2003 Graham Klyne 2009 Vasili I Galchin 2011 2012 2014 2016 2018 Douglas Burke
License | GPL V2
Maintainer | Douglas Burke
Stability | experimental
Portability | CPP, FlexibleInstances, MultiParamTypeClasses
Safe Haskell | Safe-Inferred
Language | Haskell2010

Swish.GraphMem

Description

This module defines a simple memory-based graph instance.

Synopsis

- data GraphMem lb = GraphMem {
  - arcs :: ArcSet lb
  }
- data LabelMem
  - = LF String
  - | LV String
- setArcs :: LDGraph lg lb => lg lb -> ArcSet lb -> lg lb
- getArcs :: LDGraph lg lb => lg lb -> ArcSet lb
- addGraphs :: (LDGraph lg lb, Ord lb) => lg lb -> lg lb -> lg lb
- delete :: (LDGraph lg lb, Ord lb) => lg lb -> lg lb -> lg lb
- extract :: (LDGraph lg lb, Ord lb) => Selector lb -> lg lb -> lg lb
- labels :: (LDGraph lg lb, Ord lb) => lg lb -> Set lb
- labelIsVar :: Label lb => lb -> Bool
- labelHash :: Label lb => Int -> lb -> Int
- matchGraphMem :: Label lb => GraphMem lb -> GraphMem lb -> (Bool, LabelMap (ScopedLabel lb))

# Documentation

data GraphMem lb Source #

Simple memory-based graph type.

Constructors

GraphMem |

Fields

- arcs :: ArcSet lb

#### Instances

Instances details

LDGraph GraphMem lb Source # |

Instance details

Defined in Swish.GraphMem

Methods

emptyGraph :: GraphMem lb Source #

setArcs :: GraphMem lb -> ArcSet lb -> GraphMem lb Source #

getArcs :: GraphMem lb -> ArcSet lb Source #

extract :: Selector lb -> GraphMem lb -> GraphMem lb Source #

addGraphs :: GraphMem lb -> GraphMem lb -> GraphMem lb Source #

delete :: GraphMem lb -> GraphMem lb -> GraphMem lb Source #

labels :: GraphMem lb -> Set lb Source #

nodes :: GraphMem lb -> Set lb Source #

update :: (ArcSet lb -> ArcSet lb) -> GraphMem lb -> GraphMem lb Source #

Label lb => Monoid (GraphMem lb) Source # |
Instance details Defined in Swish.GraphMem Methods mempty :: GraphMem lb Source # mappend :: GraphMem lb -> GraphMem lb -> GraphMem lb Source # mconcat :: [GraphMem lb] -> GraphMem lb Source #
Label lb => Semigroup (GraphMem lb) Source # |
Instance details Defined in Swish.GraphMem Methods (<>) :: GraphMem lb -> GraphMem lb -> GraphMem lb Source # sconcat :: NonEmpty (GraphMem lb) -> GraphMem lb Source # stimes :: Integral b => b -> GraphMem lb -> GraphMem lb Source #
Label lb => Show (GraphMem lb) Source # |
Instance details Defined in Swish.GraphMem Methods showsPrec :: Int -> GraphMem lb -> ShowS Source # show :: GraphMem lb -> String Source # showList :: [GraphMem lb] -> ShowS Source #
Label lb => Eq (GraphMem lb) Source # |
Instance details Defined in Swish.GraphMem Methods (==) :: GraphMem lb -> GraphMem lb -> Bool Source # (/=) :: GraphMem lb -> GraphMem lb -> Bool Source #
Label lb => Ord (GraphMem lb) Source # |

Instance details

Defined in Swish.GraphMem

Methods

compare :: GraphMem lb -> GraphMem lb -> Ordering Source #

(<) :: GraphMem lb -> GraphMem lb -> Bool Source #

(<=) :: GraphMem lb -> GraphMem lb -> Bool Source #

(>) :: GraphMem lb -> GraphMem lb -> Bool Source #

(>=) :: GraphMem lb -> GraphMem lb -> Bool Source #

max :: GraphMem lb -> GraphMem lb -> GraphMem lb Source #

min :: GraphMem lb -> GraphMem lb -> GraphMem lb Source #

data LabelMem Source #

Minimal graph label value - for testing

Constructors

LF String |
LV String |

#### Instances

Instances details

Show LabelMem Source # |
Instance details Defined in Swish.GraphMem Methods showsPrec :: Int -> LabelMem -> ShowS Source # show :: LabelMem -> String Source # showList :: [LabelMem] -> ShowS Source #
Eq LabelMem Source # |
Instance details Defined in Swish.GraphMem Methods (==) :: LabelMem -> LabelMem -> Bool Source # (/=) :: LabelMem -> LabelMem -> Bool Source #
Ord LabelMem Source # |
Instance details Defined in Swish.GraphMem Methods compare :: LabelMem -> LabelMem -> Ordering Source # (<) :: LabelMem -> LabelMem -> Bool Source # (<=) :: LabelMem -> LabelMem -> Bool Source # (>) :: LabelMem -> LabelMem -> Bool Source # (>=) :: LabelMem -> LabelMem -> Bool Source # max :: LabelMem -> LabelMem -> LabelMem Source # min :: LabelMem -> LabelMem -> LabelMem Source #
Hashable LabelMem Source # |
Instance details Defined in Swish.GraphMem Methods hashWithSalt :: Int -> LabelMem -> Int Source # hash :: LabelMem -> Int Source #
Label LabelMem Source # |
Instance details Defined in Swish.GraphMem Methods labelIsVar :: LabelMem -> Bool Source # labelHash :: Int -> LabelMem -> Int Source # getLocal :: LabelMem -> String Source # makeLabel :: String -> LabelMem Source #

setArcs :: LDGraph lg lb => lg lb -> ArcSet lb -> lg lb Source #

Replace the existing arcs in the graph.

getArcs :: LDGraph lg lb => lg lb -> ArcSet lb Source #

Extract all the arcs from a graph

addGraphs :: (LDGraph lg lb, Ord lb) => lg lb -> lg lb -> lg lb Source #

Add the two graphs

delete Source #

Arguments

:: (LDGraph lg lb, Ord lb) |
=> lg lb | g1
-> lg lb | g2
-> lg lb | g2 - g1 -> g3

Remove those arcs in the first graph from the second graph

extract :: (LDGraph lg lb, Ord lb) => Selector lb -> lg lb -> lg lb Source #

Extract those arcs that match the given `Selector`.

labels :: (LDGraph lg lb, Ord lb) => lg lb -> Set lb Source #

Enumerate the distinct labels contained in a graph; that is, any label that appears in the subject, predicate or object position of an `Arc`.

labelIsVar :: Label lb => lb -> Bool Source #

Does this node have a variable binding?

labelHash :: Label lb => Int -> lb -> Int Source #

Calculate the hash of the label using the supplied seed.

matchGraphMem Source #

Arguments

:: Label lb |
=> GraphMem lb |
-> GraphMem lb |
-> (Bool, LabelMap (ScopedLabel lb)) | if the first element is `True` then the second value is a label map that maps each label to an equivalence-class identifier, otherwise `emptyMap`.

GraphMem matching function accepting GraphMem value and returning node map if successful