Abstractions over a graph object, intended to sit alongside the other basic clojure data structures such as maps, vectors and sets.
Abstractions over a graph object, intended to sit alongside the other basic clojure data structures such as maps, vectors and sets.
Returns <g>, with <to-add> added
Where
<g> is a Graph
<to-add> is interpetable as a set of triples
Dispatched according to triples-format
Returns <g>, with <to-add> added Where <g> is a Graph <to-add> is interpetable as a set of triples Dispatched according to `triples-format`
An abstraction for S-P-O graphs
An abstraction for S-P-O graphs
(subjects g)
Returns (<s>...) for <g> Where <s> is a subject in one or more triples in <g> <g> is a graph.
Returns (<s>...) for <g> Where <s> is a subject in one or more triples in <g> <g> is a graph.
(query g q)
Returns #{<binding> ...} for query spec <q> applied to <g> Where <binding> := {<var> <value>, ...} <q> is a query specification suitable for the native format of <g> <g> is a graph <args> := [<arg>....] <var> is a variable specified in <q> <value> is a value found in <g> bounded to <var> per <q> <arg> is any optional value that informs native execution of the query. for example if the native platform supports a templating scheme as in datalog
Returns #{<binding> ...} for query spec <q> applied to <g> Where <binding> := {<var> <value>, ...} <q> is a query specification suitable for the native format of <g> <g> is a graph <args> := [<arg>....] <var> is a variable specified in <q> <value> is a value found in <g> bounded to <var> per <q> <arg> is any optional value that informs native execution of the query. for example if the native platform supports a templating scheme as in datalog
(get-o g s p)
Returns {<o> ...} for <s> and <p> in <g>, or nil. Where <g> is a graph <s> is subject of some triples in <g>
<p> is predicate of some triples in <g> <o> appears in triple [<s> <p> <o>] in <g>
Returns {<o> ...} for <s> and <p> in <g>, or nil. Where <g> is a graph <s> is subject of some triples in <g> <p> is predicate of some triples in <g> <o> appears in triple [<s> <p> <o>] in <g>
(ask g s p o)
Returns truthy value iff [<s> <p> <o>] appears in <g> Where <g> is a graph <s> is subject of some triples in <g>
<p> is predicate of some triples in <g> <o> appears in triple [<s> <p> <o>] in <g>
Returns truthy value iff [<s> <p> <o>] appears in <g> Where <g> is a graph <s> is subject of some triples in <g> <p> is predicate of some triples in <g> <o> appears in triple [<s> <p> <o>] in <g>
(mutability g)
Returns one of ::read-only ::immutable ::mutable ::accumulate-only
Returns one of ::read-only ::immutable ::mutable ::accumulate-only
(get-p-o g s)
Returns {<p> #{<o> ...}} associated with <s> in <g>, or nil. Where <g> is a graph <s> is subject
<p> and <o> are in triples := [<s> <p> <o>] in <g>
Returns {<p> #{<o> ...}} associated with <s> in <g>, or nil. Where <g> is a graph <s> is subject <p> and <o> are in triples := [<s> <p> <o>] in <g>
(normal-form g)
Returns {<s> {<p> #{<o>...}...}...} Where <s> is the subject of a triple := [<s> <p> <o>] in <g>
<p> is predicate of same <o> is the object of same
Returns {<s> {<p> #{<o>...}...}...} Where <s> is the subject of a triple := [<s> <p> <o>] in <g> <p> is predicate of same <o> is the object of same
(invoke g)
(invoke g s)
(invoke g s p)
(invoke g s p o)
Applies <g> as a function to the rest of its arguments, representing
triples [<s> <p> <o>] in <g> respectively. <p> may optionally be
a traversal function (See traverse
docs)
(g) -> {<s> {<p> #{<o>...}...}...} ;; = (normal-form <g>)
(g s) -> {<p> #{<o>...}, ...} ;; = (get-p-o <g>)
(g s p) -> #{<o> ...} ;; = (match-or-traverse g s p)
(g s p o) -> <o> iff [<s> <p> <o>] is in <g> ;; = (match-or-traverse g s p o)
Applies <g> as a function to the rest of its arguments, representing triples [<s> <p> <o>] in <g> respectively. <p> may optionally be a traversal function (See `traverse` docs) (g) -> {<s> {<p> #{<o>...}...}...} ;; = (normal-form <g>) (g s) -> {<p> #{<o>...}, ...} ;; = (get-p-o <g>) (g s p) -> #{<o> ...} ;; = (match-or-traverse g s p) (g s p o) -> <o> iff [<s> <p> <o>] is in <g> ;; = (match-or-traverse g s p o)
(claim g to-add)
Returns <g>, with <to-add> added to <g>'s associated transactor. Throws an exception if (mutability g) != ::accumulate-only Where <g> is a mutable graph <to-add> is in triples-format NOTE: see Datomic documentation for the 'add' operation for details
Returns <g>, with <to-add> added to <g>'s associated transactor. Throws an exception if (mutability g) != ::accumulate-only Where <g> is a mutable graph <to-add> is in triples-format NOTE: see Datomic documentation for the 'add' operation for details
(retract g to-retract)
Returns <g> with <comm> reset to head Side-effect: <to-retract> retracted from <comm> Throws an exception if (mutability g) != ::accumulate-only. Where <g> is a graph <comm> is a datomic-style transactor <to-retract> is in triples-removal-format NOTE: see Datomic documentation for details
Returns <g> with <comm> reset to head Side-effect: <to-retract> retracted from <comm> Throws an exception if (mutability g) != ::accumulate-only. Where <g> is a graph <comm> is a datomic-style transactor <to-retract> is in triples-removal-format NOTE: see Datomic documentation for details
(add g to-add)
Returns <g>', with <to-add> added to its contents. Throws a ::ReadOnly exception if (read-only? <g>) Where <g> is a graph <to-add> is in triples-format
Returns <g>', with <to-add> added to its contents. Throws a ::ReadOnly exception if (read-only? <g>) Where <g> is a graph <to-add> is in triples-format
(subtract g to-subtract)
Returns <g>' with <to-subtract> removed from its contents. Throws an exception if (mutability g) != ::immutable Where <g> is an immutablegraph <to-subtract> is in triples-removal-format
Returns <g>' with <to-subtract> removed from its contents. Throws an exception if (mutability g) != ::immutable Where <g> is an immutablegraph <to-subtract> is in triples-removal-format
(add! g to-add)
Returns <g>, with <to-add> added to its contents. Throws an exception if (mutability g) != ::mutable Where <g> is a mutable graph <to-add> is in triples-format
Returns <g>, with <to-add> added to its contents. Throws an exception if (mutability g) != ::mutable Where <g> is a mutable graph <to-add> is in triples-format
(subtract! g to-subtract)
Returns <g> with <to-subtract> removed from its contents. Throws a ::ReadOnly exception if (read-only? <g>) Where <g> is a graph <to-subtract> is in triples-removal-format
Returns <g> with <to-subtract> removed from its contents. Throws a ::ReadOnly exception if (read-only? <g>) Where <g> is a graph <to-subtract> is in triples-removal-format
Basic set operations between graphs.
Basic set operations between graphs.
(difference g1 g2)
Returns an IGraph whose normal form contains all statements in g1 not present in g2.
Returns an IGraph whose normal form contains all statements in g1 not present in g2.
(intersection g1 g2)
Returns an IGraph whose normal form contains all and only statements shared by both g1 and g2
Returns an IGraph whose normal form contains all and only statements shared by both g1 and g2
(union g1 g2)
Returns an IGraph whose normal form contains all triples from g1 and g2
Returns an IGraph whose normal form contains all triples from g1 and g2
Returns values appropriate for (g s p) or (g s p o) invocations Where <o> is an object in <g> <s> is a subject in <g>
<p> is either a predicate in <g> or a traversal function accumulating a set, starting with an empty accumulator and queue of [<s>] (see docs for `traverse`) NOTE: Implementers of IGraph will typically use this method for IFn `invoke` members involving a <p> argument.
Returns values appropriate for (g s p) or (g s p o) invocations Where <o> is an object in <g> <s> is a subject in <g> <p> is either a predicate in <g> or a traversal function accumulating a set, starting with an empty accumulator and queue of [<s>] (see docs for `traverse`) NOTE: Implementers of IGraph will typically use this method for IFn `invoke` members involving a <p> argument.
(normal-form? m)
Returns true iff <m> is in normal form for IGraph.
Returns true iff <m> is in normal form for IGraph.
(normalize-flat-description m)
Returns a normalized p-o description of m
Where
<m> is a plain clojure map
Returns a normalized p-o description of `m` Where <m> is a plain clojure map
(p-dispatcher g s p)
(p-dispatcher g s p o)
Returns :traverse or :match, as a basis for dispatching standard invoke
methods involving a <p> argument, which may be either a value ot match or a traversal function.
Returns :traverse or :match, as a basis for dispatching standard `invoke` methods involving a <p> argument, which may be either a value ot match or a traversal function.
Returns <g>, with <to-remove> removed
Where
<g> is a Graph
<to-add> is interpetable as a set of triples
Dispatched according to triples-removal-format
Returns <g>, with <to-remove> removed Where <g> is a Graph <to-add> is interpetable as a set of triples Dispatched according to `triples-removal-format`
(transitive-closure p)
Returns <traversal> for chains of p
.
Where
<traversal> := (fn [g acc queue]...) -> [<context> <acc'> <queue'>],
s.t. <queue'> conj's all <o> s.t. (g <s> <p> <o>).
A traversal function argument for the traverse
function .
<p> is a predicate, typcially an element of <g> <g> is a graph. NOTE: cf the '*' operator in SPARQL property paths
Returns <traversal> for chains of `p`. Where <traversal> := (fn [g acc queue]...) -> [<context> <acc'> <queue'>], s.t. <queue'> conj's all <o> s.t. (g <s> <p> <o>). A traversal function argument for the `traverse` function . <p> is a predicate, typcially an element of <g> <g> is a graph. NOTE: cf the '*' operator in SPARQL property paths
(traverse g traversal acc queue)
(traverse g traversal context acc queue)
Returns acc
acquired by applying traversal
to g
starting with queue
, informed by context
Where
<acc> is an arbitrary clojure 'accumulator' object (similar to a
reduce function)
<traversal> := (fn [g context acc queue]...)
-> [<context'> <acc'> <queue'>]
<g> is a graph
<context> := {<context-key> <context-value>....}, expressing important
aspects of the traversal state
<queue> := [<node> ...], nodes to visit
<context-key> := #{:history ... maybe :skip? ... :seek ... or other
keys specific to <traversal>, which <traversal> may use to communicate
with future iterations of itself.
<history> := #{<visited-node> ...}, this is conj'd with each visited node on
each call to avoid cycles.
<skip?> (optional) := (fn [<node>] -> true if we should skip). This may also
be a set of nodes to skip. This allows for overriding the default skipping
behavior which simply skips <history>
<seek> (optional) := (fn [context acc] -> <acc'>, a function to be called
at the start of each traversal, a truthy, non-empty response to which will
be the immediate return value of the traverse function. This would save you
the time and trouble of processing the whole queue, or making each traversal
function smart enough to stop early. Must return the same type as <acc>.
<node> is typically an element in <g>, but can be any value the traversal
function knows how to handle
<visited-node> is a node visited upstream. We filter these out to
avoid cycles. This can also be specified in advance by the user.
<target> is a node we may be searching for.
Note: it is good practice to assign a :transition-fn metadata tag to
transition functions, though such data is not referenced anywhere
at this point.
Returns `acc` acquired by applying `traversal` to `g` starting with `queue`, informed by `context` Where <acc> is an arbitrary clojure 'accumulator' object (similar to a reduce function) <traversal> := (fn [g context acc queue]...) -> [<context'> <acc'> <queue'>] <g> is a graph <context> := {<context-key> <context-value>....}, expressing important aspects of the traversal state <queue> := [<node> ...], nodes to visit <context-key> := #{:history ... maybe :skip? ... :seek ... or other keys specific to <traversal>, which <traversal> may use to communicate with future iterations of itself. <history> := #{<visited-node> ...}, this is conj'd with each visited node on each call to avoid cycles. <skip?> (optional) := (fn [<node>] -> true if we should skip). This may also be a set of nodes to skip. This allows for overriding the default skipping behavior which simply skips <history> <seek> (optional) := (fn [context acc] -> <acc'>, a function to be called at the start of each traversal, a truthy, non-empty response to which will be the immediate return value of the traverse function. This would save you the time and trouble of processing the whole queue, or making each traversal function smart enough to stop early. Must return the same type as <acc>. <node> is typically an element in <g>, but can be any value the traversal function knows how to handle <visited-node> is a node visited upstream. We filter these out to avoid cycles. This can also be specified in advance by the user. <target> is a node we may be searching for. Note: it is good practice to assign a :transition-fn metadata tag to transition functions, though such data is not referenced anywhere at this point.
(traverse-link p)
Returns traversal function (fn [g context, acc queue]...) -> [context, acc', queue'], following one <p> in <g> Where <acc> is a set <queue> := [<node> ...], nodes to visit in traversal
<p> is a predicate in <g> <g> is a graph
NOTE: typically used as one component in a traversal path
Returns traversal function (fn [g context, acc queue]...) -> [context, acc', queue'], following one <p> in <g> Where <acc> is a set <queue> := [<node> ...], nodes to visit in traversal <p> is a predicate in <g> <g> is a graph NOTE: typically used as one component in a traversal path
(triples-format triples-spec)
Returns the value of (:triples-format (meta <triples-spec>)) or one of #{:vector :vector-of-vectors :normal-form <type>} inferred from the shape of <triples-spec> Where <args> := [<g> <triples-spec>], arguments to a method add or remove from graph <g> is a graph <triples-spec> is a specification of triples typically to add to or remove from <g> :normal-form indicates (normal-form? <triples-spec>) = true :triple indicates <triples-spec> := [<s> <p> <o>] :vector-of-vectors indicates <triples-spec> := [<triple>...] <type> = (type <triples-spec>)
Returns the value of (:triples-format (meta <triples-spec>)) or one of #{:vector :vector-of-vectors :normal-form <type>} inferred from the shape of <triples-spec> Where <args> := [<g> <triples-spec>], arguments to a method add or remove from graph <g> is a graph <triples-spec> is a specification of triples typically to add to or remove from <g> :normal-form indicates (normal-form? <triples-spec>) = true :triple indicates <triples-spec> := [<s> <p> <o>] :vector-of-vectors indicates <triples-spec> := [<triple>...] <type> = (type <triples-spec>)
(triples-removal-format triples-spec)
Returns a keyword describing the format of triples-spec
for removing a
set of triples from a graph.
Returns a keyword describing the format of `triples-spec` for removing a set of triples from a graph.
(unique coll)
(unique coll on-ambiguity)
Returns the single member of <coll>, or nil if <coll> is empty. Calls <on-ambiguity> if there is more than one member (default is to throw an Exception). Where <coll> is a collection <on-ambiguity> := (fn [coll] ...) -> <value>, default raises an error. Note: this can be used when you've called (G s p) and you're sure there is only one object.
Returns the single member of <coll>, or nil if <coll> is empty. Calls <on-ambiguity> if there is more than one member (default is to throw an Exception). Where <coll> is a collection <on-ambiguity> := (fn [coll] ...) -> <value>, default raises an error. Note: this can be used when you've called (G s p) and you're sure there is only one object.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close