Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Stardog 2.2 graph analytics embedded in SPARQL queries
# graph for shortest path with reasoning
@prefix rule: <tag:stardog:api:rule:> .
@prefix : <urn:test:> .
@prefix g: <tag:stardog:api:property:graph:> .
# the graph
:one :to :two .
:one :to :four .
:two :to :four .
:two :to :five .
:three :to :one .
:three :to :six .
:four :to :three .
:four :to :five .
:four :to :six .
:four :to :seven .
:five :to :seven .
:seven :to :six .
:eight :to :nine .
:nine :to :ten .
:ten :to :eight .
:five a :reasoner .
# the rules
[] a rule:SPARQLRule ;
rule:content """
IF {
?node a :reasoner
}
THEN {
?node :to :nine
}
""".
select ?s ?score {
(?s ?score) stardog:property:graph:pageRank (100 .80)
}
order by ?score
limit 10
prefix uni: <http://www.Department0.University0.edu/>
select ?index ?source ?predicate ?target {
(?source ?predicate ?target ?index) stardog:property:graph:shortestPath (uni:UndergraduateStudent299 uni:Course0)
}
select distinct ?cluster ?subject {
(?cluster ?subject) stardog:property:graph:strongComponents ()
}
order by ?cluster
# from StrongComponentsTest.java
@prefix : <urn:test:> .
@prefix g: <tag:stardog:api:property:graph:> .
:one :to :two .
:two :to :four .
:three :to :two .
:three :to :four .
:three :to :six .
:four :to :one .
:five :to :four .
:five :to :eight .
:six :to :three .
:six :to :five .
:seven :to :six .
:seven :to :seven .
:seven :to :eight .
:eight :to :five .
select ?cluster (count(?cluster) as ?count) {
(?cluster ?subject) stardog:property:graph:weakComponents ()
}
group by ?cluster
order by ?cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.