swish-0.9.2.1: A semantic web toolkit.

Copyright(c) 2003 Graham Klyne 2009 Vasili I Galchin
2011 2012 2016 Douglas Burke
LicenseGPL V2
MaintainerDouglas Burke
Stabilityexperimental
PortabilityCPP, DeriveFunctor, DeriveFoldable, DeriveTraversable, MultiParamTypeClasses
Safe HaskellSafe
LanguageHaskell98

Swish.GraphClass

Description

This module defines a Labelled Directed Graph and Label classes, and the Arc datatype.

Synopsis

Documentation

class LDGraph lg lb where #

Labelled Directed Graph class.

Minimum required implementation: emptyGraph, setArcs, and getArcs.

Minimal complete definition

emptyGraph, setArcs, getArcs

Methods

emptyGraph :: lg lb #

Create the empty graph.

setArcs :: lg lb -> ArcSet lb -> lg lb #

Replace the existing arcs in the graph.

getArcs :: lg lb -> ArcSet lb #

Extract all the arcs from a graph

extract :: Ord lb => Selector lb -> lg lb -> lg lb #

Extract those arcs that match the given Selector.

addGraphs :: Ord lb => lg lb -> lg lb -> lg lb #

Add the two graphs

delete #

Arguments

:: Ord lb 
=> lg lb

g1

-> lg lb

g2

-> lg lb

g2 - g1 -> g3

Remove those arcs in the first graph from the second graph

labels :: Ord lb => lg lb -> Set lb #

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

nodes :: Ord lb => lg lb -> Set lb #

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

update :: (ArcSet lb -> ArcSet lb) -> lg lb -> lg lb #

Update the arcs in a graph using a supplied function.

Instances

LDGraph GraphMem lb # 

Methods

emptyGraph :: GraphMem lb #

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

getArcs :: GraphMem lb -> ArcSet lb #

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

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

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

labels :: GraphMem lb -> Set lb #

nodes :: GraphMem lb -> Set lb #

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

LDGraph NSGraph lb # 

Methods

emptyGraph :: NSGraph lb #

setArcs :: NSGraph lb -> ArcSet lb -> NSGraph lb #

getArcs :: NSGraph lb -> ArcSet lb #

extract :: Selector lb -> NSGraph lb -> NSGraph lb #

addGraphs :: NSGraph lb -> NSGraph lb -> NSGraph lb #

delete :: NSGraph lb -> NSGraph lb -> NSGraph lb #

labels :: NSGraph lb -> Set lb #

nodes :: NSGraph lb -> Set lb #

update :: (ArcSet lb -> ArcSet lb) -> NSGraph lb -> NSGraph lb #

class (Ord lb, Show lb) => Label lb where #

Label class.

A label may have a fixed binding, which means that the label identifies (is) a particular graph node, and different such labels are always distinct nodes. Alternatively, a label may be unbound (variable), which means that it is a placeholder for an unknown node label. Unbound node labels are used as graph-local identifiers for indicating when the same node appears in several arcs.

For the purposes of graph-isomorphism testing, fixed labels are matched when they are the same. Variable labels may be matched with any other variable label. Our definition of isomorphism (for RDF graphs) does not match variable labels with fixed labels.

Minimal complete definition

labelIsVar, labelHash, getLocal, makeLabel

Methods

labelIsVar :: lb -> Bool #

Does this node have a variable binding?

labelHash :: Int -> lb -> Int #

Calculate the hash of the label using the supplied seed.

getLocal :: lb -> String #

Extract the local id from a variable node.

makeLabel :: String -> lb #

Make a label value from a local id.

data Arc lb #

Arc type.

Prior to 0.7.0.0 you could also use asubj, apred and aobj to access the elements of the arc.

Constructors

Arc 

Fields

  • arcSubj :: lb

    The subject of the arc.

  • arcPred :: lb

    The predicate (property) of the arc.

  • arcObj :: lb

    The object of the arc.

Instances

Functor Arc # 

Methods

fmap :: (a -> b) -> Arc a -> Arc b #

(<$) :: a -> Arc b -> Arc a #

Foldable Arc # 

Methods

fold :: Monoid m => Arc m -> m #

foldMap :: Monoid m => (a -> m) -> Arc a -> m #

foldr :: (a -> b -> b) -> b -> Arc a -> b #

foldr' :: (a -> b -> b) -> b -> Arc a -> b #

foldl :: (b -> a -> b) -> b -> Arc a -> b #

foldl' :: (b -> a -> b) -> b -> Arc a -> b #

foldr1 :: (a -> a -> a) -> Arc a -> a #

foldl1 :: (a -> a -> a) -> Arc a -> a #

toList :: Arc a -> [a] #

null :: Arc a -> Bool #

length :: Arc a -> Int #

elem :: Eq a => a -> Arc a -> Bool #

maximum :: Ord a => Arc a -> a #

minimum :: Ord a => Arc a -> a #

sum :: Num a => Arc a -> a #

product :: Num a => Arc a -> a #

Traversable Arc # 

Methods

traverse :: Applicative f => (a -> f b) -> Arc a -> f (Arc b) #

sequenceA :: Applicative f => Arc (f a) -> f (Arc a) #

mapM :: Monad m => (a -> m b) -> Arc a -> m (Arc b) #

sequence :: Monad m => Arc (m a) -> m (Arc a) #

Eq lb => Eq (Arc lb) # 

Methods

(==) :: Arc lb -> Arc lb -> Bool #

(/=) :: Arc lb -> Arc lb -> Bool #

Ord lb => Ord (Arc lb) # 

Methods

compare :: Arc lb -> Arc lb -> Ordering #

(<) :: Arc lb -> Arc lb -> Bool #

(<=) :: Arc lb -> Arc lb -> Bool #

(>) :: Arc lb -> Arc lb -> Bool #

(>=) :: Arc lb -> Arc lb -> Bool #

max :: Arc lb -> Arc lb -> Arc lb #

min :: Arc lb -> Arc lb -> Arc lb #

Show lb => Show (Arc lb) # 

Methods

showsPrec :: Int -> Arc lb -> ShowS #

show :: Arc lb -> String #

showList :: [Arc lb] -> ShowS #

Hashable lb => Hashable (Arc lb) # 

Methods

hashWithSalt :: Int -> Arc lb -> Int #

hash :: Arc lb -> Int #

type ArcSet lb = Set (Arc lb) #

A set - or graph - of arcs.

type Selector lb = Arc lb -> Bool #

Identify arcs.

arc #

Arguments

:: lb

The subject of the arc.

-> lb

The predicate of the arc.

-> lb

The object of the arc.

-> Arc lb 

Create an arc.

arcToTriple :: Arc lb -> (lb, lb, lb) #

Convert an Arc into a tuple.

arcFromTriple :: (lb, lb, lb) -> Arc lb #

Create an Arc from a tuple.

hasLabel :: Eq lb => lb -> Arc lb -> Bool #

Does the arc contain the label in any position (subject, predicate, or object)?

arcLabels :: Arc lb -> [lb] #

Return all the labels in an arc.

getComponents :: Ord b => (a -> [b]) -> Set a -> Set b #

Extract components from a set.