A set of SPARQL examples that are used in different TGX resources
License: https://www.gnu.org/licenses/gpl-3.0
Uses method in: https://github.com/WDscholia/scholia/tree/master/scholia/app/templates/author_academic-tree.sparql
Author aspect: academic tree
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
#defaultView:Graph
PREFIX target: <http://www.wikidata.org/entity/Q97270>
# Doctoral student/advisor network with a source from a spectific researcher
PREFIX gas: <http://www.bigdata.com/rdf/gas#>
SELECT DISTINCT ?student1 ?student1Label ?rgb ?supervisor1 ?supervisor1Label
WHERE {
{
SELECT ?student1 ?supervisor1 (MIN(?depth1) as ?depth)
WHERE {
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ;
gas:in target: ;
gas:traversalDirection "Forward" ;
gas:out ?student1 ;
gas:out1 ?depth1 ;
gas:out2 ?supervisor1 ;
gas:linkType wdt:P185 ;
}
}
GROUP BY ?student1 ?supervisor1
}
UNION
{
SELECT ?student1 ?supervisor1 (MIN(?depth1) as ?depth)
WHERE {
service gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ;
gas:in target: ;
gas:traversalDirection "Forward" ;
gas:out ?supervisor1 ;
gas:out1 ?depth1 ;
gas:out2 ?student1 ;
gas:linkType wdt:P184 ;
}
}
GROUP BY ?student1 ?supervisor1
}
UNION
{
SELECT ?student1 ?supervisor1 (MIN(?depth1) as ?depth)
WHERE {
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ;
gas:in target: ;
gas:traversalDirection "Reverse" ;
gas:out ?student1 ;
gas:out1 ?depth1 ;
gas:out2 ?supervisor1 ;
gas:linkType wdt:P184 ;
}
}
GROUP BY ?student1 ?supervisor1
}
UNION
{
SELECT ?student1 ?supervisor1 (MIN(?depth1) as ?depth)
WHERE {
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" ;
gas:in target: ;
gas:traversalDirection "Reverse" ;
gas:out ?supervisor1 ;
gas:out1 ?depth1 ;
gas:out2 ?student1 ;
gas:linkType wdt:P185 ;
}
}
GROUP BY ?student1 ?supervisor1
}
BIND( IF( ?student1 = target:, "3080BB", "ffffff") AS ?rgb)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?depth")
v2("?depth1")
v5("?rgb"):::projected
v1("?student1"):::projected
v3("?supervisor1"):::projected
c2([http://www.bigdata.com/rdf/gas#program]):::iri
c15(["Reverse"]):::literal
c6([http://www.wikidata.org/entity/Q97270]):::iri
c19(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal
c13(["p:direct/P185"]):::iri
c14(["p:direct/P184"]):::iri
c4(["com.bigdata.rdf.graph.analytics.BFS"]):::literal
c17([http://www.bigdata.com/rdf#serviceParam]):::iri
c8(["Forward"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
subgraph union2[" Union "]
subgraph union2l[" "]
style union2l fill:#abf,stroke-dasharray: 3 3;
subgraph s1["http://www.bigdata.com/rdf/gas#service"]
style s1 stroke-width:4px;
c2 --http://www.bigdata.com/rdf/gas#gasClass--> c4
c2 --http://www.bigdata.com/rdf/gas#in--> c6
c2 --http://www.bigdata.com/rdf/gas#traversalDirection--> c15
c2 --http://www.bigdata.com/rdf/gas#out--> v3
c2 --http://www.bigdata.com/rdf/gas#out1--> v2
c2 --http://www.bigdata.com/rdf/gas#out2--> v1
c2 --http://www.bigdata.com/rdf/gas#linkType--> c13
end
bind1[/"min(?depth1)"/]
v2 --o bind1
bind1 --as--o v5
end
subgraph union2r[" "]
style union2r fill:#abf,stroke-dasharray: 3 3;
subgraph s1["http://www.bigdata.com/rdf/gas#service"]
style s1 stroke-width:4px;
c2 --http://www.bigdata.com/rdf/gas#gasClass--> c4
c2 --http://www.bigdata.com/rdf/gas#in--> c6
c2 --http://www.bigdata.com/rdf/gas#traversalDirection--> c15
c2 --http://www.bigdata.com/rdf/gas#out--> v1
c2 --http://www.bigdata.com/rdf/gas#out1--> v2
c2 --http://www.bigdata.com/rdf/gas#out2--> v3
c2 --http://www.bigdata.com/rdf/gas#linkType--> c14
end
bind3[/"min(?depth1)"/]
v2 --o bind3
bind3 --as--o v5
end
union2r <== or ==> union2l
end
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
subgraph s1["http://www.bigdata.com/rdf/gas#service"]
style s1 stroke-width:4px;
c2 --http://www.bigdata.com/rdf/gas#gasClass--> c4
c2 --http://www.bigdata.com/rdf/gas#in--> c6
c2 --http://www.bigdata.com/rdf/gas#traversalDirection--> c8
c2 --http://www.bigdata.com/rdf/gas#out--> v3
c2 --http://www.bigdata.com/rdf/gas#out1--> v2
c2 --http://www.bigdata.com/rdf/gas#out2--> v1
c2 --http://www.bigdata.com/rdf/gas#linkType--> c14
end
bind5[/"min(?depth1)"/]
v2 --o bind5
bind5 --as--o v5
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
subgraph s1["http://www.bigdata.com/rdf/gas#service"]
style s1 stroke-width:4px;
c2 --http://www.bigdata.com/rdf/gas#gasClass--> c4
c2 --http://www.bigdata.com/rdf/gas#in--> c6
c2 --http://www.bigdata.com/rdf/gas#traversalDirection--> c8
c2 --http://www.bigdata.com/rdf/gas#out--> v1
c2 --http://www.bigdata.com/rdf/gas#out1--> v2
c2 --http://www.bigdata.com/rdf/gas#out2--> v3
c2 --http://www.bigdata.com/rdf/gas#linkType--> c13
end
bind7[/"min(?depth1)"/]
v2 --o bind7
bind7 --as--o v5
end
union0r <== or ==> union0l
end
bind8[/"if(?student1 = http://www.wikidata.org/entity/Q97270,'3080BB','ffffff')"/]
v1 --o bind8
bind8 --as--o v5
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c17 --"wikibase:language"--> c19
end