Implementation of a simple graph type implementing IGraph. On typically adds to it with [[<s> <p> <o>]...]. One queries it with a simple graph pattern of the form [[<s> <p> <o>]...] With variables of the form :?x.
The core type declaration:
(deftype Graph [schema contents]
IGraph (normal-form [g] (.contents g)) (subjects [g] (lazy-seq (keys (.contents g)))) (get-p-o [g s] (get (.contents g) s)) (get-o [g s p] (get-in (.contents g) [s p])) (ask [g s p o] (get-in (.contents g) [s p o])) (query [g q] (query-graph g q)) (add [g to-add] (add-to-graph g to-add)) (subtract [g to-subtract] (remove-from-graph g to-subtract))
clojure.lang.IFn (invoke [g] (normal-form g)) (invoke [g s] (get-p-o g s)) (invoke [g s p] (match-or-traverse g s p)) (invoke [g s p o] (match-or-traverse g s p o))
IGraphSet (union [g1 g2] (add-to-graph g1 (g2))) (intersection [g1 g2] (get-intersection g1 g2)) (difference [g1 g2] (remove-from-graph g1 (g2))) )
Implementation of a simple graph type implementing IGraph. On typically adds to it with [[<s> <p> <o>]...]. One queries it with a simple graph pattern of the form [[<s> <p> <o>]...] With variables of the form :?x. The core type declaration: (deftype Graph [schema contents] IGraph (normal-form [g] (.contents g)) (subjects [g] (lazy-seq (keys (.contents g)))) (get-p-o [g s] (get (.contents g) s)) (get-o [g s p] (get-in (.contents g) [s p])) (ask [g s p o] (get-in (.contents g) [s p o])) (query [g q] (query-graph g q)) (add [g to-add] (add-to-graph g to-add)) (subtract [g to-subtract] (remove-from-graph g to-subtract)) clojure.lang.IFn (invoke [g] (normal-form g)) (invoke [g s] (get-p-o g s)) (invoke [g s p] (match-or-traverse g s p)) (invoke [g s p o] (match-or-traverse g s p o)) IGraphSet (union [g1 g2] (add-to-graph g1 (g2))) (intersection [g1 g2] (get-intersection g1 g2)) (difference [g1 g2] (remove-from-graph g1 (g2))) )
(get-intersection g1 g2)
Returns a new graph whose triples are shared between g1
and g2
Where
<g1> and <g2> both implement IGraph.
Returns a new graph whose triples are shared between `g1` and `g2` Where <g1> and <g2> both implement IGraph.
(kw-starts-with-? spec)
Returns true iff <spec> is a symbol whose name starts with ?. Default for query-var? parameter
Returns true iff <spec> is a symbol whose name starts with ?. Default for query-var? parameter
(make-graph & {:keys [contents] :or {contents {}}})
Returns <graph>, intialized per optional <contents>
Where
<graph> is an instance of the Graph
type, which implments IGraph
, Ifn
and ISet
<contents> is a normal-form representation of initial contents.
see also igraph/normal-form.
Returns <graph>, intialized per optional <contents> Where <graph> is an instance of the `Graph` type, which implments `IGraph`, `Ifn` and `ISet` <contents> is a normal-form representation of initial contents. see also igraph/normal-form.
(query-graph g graph-pattern)
(query-graph g graph-pattern query-var?)
Returns #{<binding>...} for <graph-pattern> applied to <g> Where <g> is a Graph <graph-pattern> := [[<var-or-value> <var-or-value> <var-or-value>]...] <var-or-value> is in #{<var> <value>} <var> is a keyword whose name begins with '?' <value> is a value which must match an element of <g> exactly. <binding> := {<var> <matching-value>, ...} <matching-value> matches <var> within <graph-pattern> applied to <g>
Returns #{<binding>...} for <graph-pattern> applied to <g> Where <g> is a Graph <graph-pattern> := [[<var-or-value> <var-or-value> <var-or-value>]...] <var-or-value> is in #{<var> <value>} <var> is a keyword whose name begins with '?' <value> is a value which must match an element of <g> exactly. <binding> := {<var> <matching-value>, ...} <matching-value> matches <var> within <graph-pattern> applied to <g>
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close