query-60167979db9720c417d90723efb5c643
Show graph elements by propertyI would like to show all bridges across a river in a graph in the order in which they appear on the river (order by upstream/downstream). Right now I have the following query
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#All bridges on Thur with upstream/downstream bridge
#defaultView:Graph
PREFIX gas: <http://www.bigdata.com/rdf/gas#>
SELECT ?item ?itemLabel ?linkTo ?pic ?depth
WHERE
{
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.SSSP" ;
gas:in wd:Q96108174 ; ## This is my work-around
#gas:in wdt:P177 wd:Q14339 ; ## This is what I would want!
gas:traversalDirection "Forward" ;
gas:out ?item ;
gas:maxVisited 150;
gas:out1 ?depth ;
gas:linkType wdt:P2674
}
OPTIONAL { ?item wdt:P2674 ?linkTo }
OPTIONAL { ?item wdt:P18 ?pic }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?depth
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?depth"):::projected
v2("?item"):::projected
v3("?linkTo"):::projected
v4("?pic"):::projected
c2(["gas:program"]):::iri
c4(["com.bigdata.rdf.graph.analytics.SSSP"]):::literal
c14(["wdt:P2674"]):::iri
c11(["150^^xsd:integer"]):::literal
c6(["wd:Q96108174"]):::iri
c17(["bd:serviceParam"]):::iri
c8(["Forward"]):::literal
c19(["#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph s1["http://www.bigdata.com/rdf/gas#service"]
style s1 stroke-width:4px;
c2 --"gas:gasClass"--> c4
c2 --"gas:in"--> c6
c2 --"gas:traversalDirection"--> c8
c2 --"gas:out"--> v2
c2 --"gas:maxVisited"--> c11
c2 --"gas:out1"--> v1
c2 --"gas:linkType"--> c14
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -->c14--> v3
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P18".-> v4
end
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c17 --"wikibase:language"--> c19
end