Portability | CPP, DeriveFunctor, DeriveFoldable, DeriveTraversable, MultiParamTypeClasses |
---|---|

Stability | experimental |

Maintainer | Douglas Burke |

Safe Haskell | None |

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

- class LDGraph lg lb where
- emptyGraph :: lg lb
- setArcs :: lg lb -> ArcSet lb -> lg lb
- getArcs :: lg lb -> ArcSet lb
- extract :: Ord lb => Selector lb -> lg lb -> lg lb
- addGraphs :: Ord lb => lg lb -> lg lb -> lg lb
- delete :: Ord lb => lg lb -> lg lb -> lg lb
- labels :: Ord lb => lg lb -> Set lb
- nodes :: Ord lb => lg lb -> Set lb
- update :: (ArcSet lb -> ArcSet lb) -> lg lb -> lg lb

- class (Ord lb, Show lb) => Label lb where
- data Arc lb = Arc {}
- type ArcSet lb = Set (Arc lb)
- type Selector lb = Arc lb -> Bool
- arc :: lb -> lb -> lb -> Arc lb
- arcToTriple :: Arc lb -> (lb, lb, lb)
- arcFromTriple :: (lb, lb, lb) -> Arc lb
- hasLabel :: Eq lb => lb -> Arc lb -> Bool
- arcLabels :: Arc lb -> [lb]
- getComponents :: (Ord a, Ord b) => (a -> [b]) -> Set a -> Set b

# Documentation

class LDGraph lg lb whereSource

Labelled Directed Graph class.

Minimum required implementation:
`emptyGraph`

, `setArcs`

, and `getArcs`

.

emptyGraph :: lg lbSource

Create the empty graph.

setArcs :: lg lb -> ArcSet lb -> lg lbSource

Replace the existing arcs in the graph.

getArcs :: lg lb -> ArcSet lbSource

Extract all the arcs from a graph

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

Extract those arcs that match the given `Selector`

.

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

Add the two graphs

:: 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 lbSource

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 lbSource

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 lbSource

Update the arcs in a graph using a supplied function.

class (Ord lb, Show lb) => Label lb whereSource

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.

labelIsVar :: lb -> BoolSource

Does this node have a variable binding?

labelHash :: Int -> lb -> IntSource

Calculate the hash of the label using the supplied seed.

getLocal :: lb -> StringSource

Extract the local id from a variable node.

makeLabel :: String -> lbSource

Make a label value from a local id.

Arc type.

Prior to `0.7.0.0`

you could also use `asubj`

, `apred`

and `aobj`

to access the elements of the arc.

:: 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)Source

Convert an Arc into a tuple.

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

Create an Arc from a tuple.