query-e58ddbf763c8fc18b4a2a839fbc57511
Stations on the Piccadilly Line, in order from Cockfosters (almost)
SELECT ?station ?station_label ?depth WITH { SELECT DISTINCT ?station WHERE { ?station p:P197/pq:P81 wd:Q207689 . } } AS %piccadillyLine WHERE { INCLUDE %piccadillyLine. { SERVICE gas:service { gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" . gas:program gas:linkType wdt:P197 . gas:program gas:in wd:Q1105305 . gas:program gas:out ?station . gas:program gas:out1 ?depth . gas:program gas:maxIterations 20 . } } ?station rdfs:label ?station_label. FILTER(LANG(?station_label) = "en") } ORDER BY ?depth
Use at
- https://query.wikidata.org/sparql
PREFIX gas: <http://www.bigdata.com/rdf/gas#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
# Stations on the Piccadilly Line, in order from Cockfosters (almost)
SELECT ?station ?station_label ?depth
WHERE {
{
SELECT DISTINCT ?station WHERE {
?station p:P197/pq:P81 wd:Q207689 .
}
}
{
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" .
gas:program gas:linkType wdt:P197 .
gas:program gas:in wd:Q1105305 .
gas:program gas:out ?station .
gas:program gas:out1 ?depth .
gas:program gas:maxIterations 20 .
}
}
?station rdfs:label ?station_label. FILTER(LANG(?station_label) = "en")
} ORDER BY ?depth
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?depth"):::projected
v3("?station"):::projected
v2("?station_label"):::projected
a1((" "))
c6(["gas:program"]):::iri
c8(["com.bigdata.rdf.graph.analytics.SSSP"]):::literal
c12(["wd:Q1105305"]):::iri
c4(["wd:Q207689"]):::iri
c10(["p:direct/P197"]):::iri
c16(["20^^xsd:integer"]):::literal
f0[["?station_label = 'en'"]]
f0 --> v2
v3 --"p:P197"--> a1
a1 --"p:qualifier/P81"--> c4
subgraph s1["http://www.bigdata.com/rdf/gas#service"]
style s1 stroke-width:4px;
c6 --"gas:gasClass"--> c8
c6 --"gas:linkType"--> c10
c6 --"gas:in"--> c12
c6 --"gas:out"--> v3
c6 --"gas:out1"--> v1
c6 --"gas:maxIterations"--> c16
end
v3 --"rdfs:label"--> v2