query-f65e6e8b4118ff2f39eb795f9ee9e135
Encontrar la distancia más corta entre dos nodos, a través de la propiedad P279 (También puede usarse con ?linkType para cualquier relación
Elemento destino "Obra literaria" Q7725634
Uso del servicio GAS
PREFIX gas: http://www.bigdata.com/rdf/gas# SELECT ?depth ?predecessor ?predecessorLabel ?out ?outLabel { SERVICE gas:service { gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" . gas:program gas:in wd:Q2831984 . # one or more times, specifies the initial frontier. gas:program gas:target wd:Q7725634 . # only retain vertices along paths to these target vertices. gas:program gas:out ?out . # exactly once - will be bound to the visited vertices. gas:program gas:out1 ?depth . # exactly once - will be bound to the depth of the visited vertices. gas:program gas:out2 ?predecessor . # exactly once - will be bound to the predecessor. gas:program gas:maxIterations 16 . # optional limit on breadth first expansion. gas:program gas:maxVisited 2000 . # optional limit on the #of visited vertices. } ?predecessor wdt:P279 ?out . # figure out what link type(s) connect a vertex with a predecessor FILTER(STRSTARTS(STR(?predecessor), "http://www.wikidata.org/entity/Q")) SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". } } order by desc(?depth) limit 100
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#>
# Encontrar la distancia más corta entre dos nodos, a través de la propiedad P279 (También puede usarse con ?linkType para cualquier relación
# Elemento destino "Obra literaria" Q7725634
# Uso del servicio GAS
PREFIX gas: <http://www.bigdata.com/rdf/gas#>
SELECT ?depth ?predecessor ?predecessorLabel ?out ?outLabel {
SERVICE gas:service {
gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" .
gas:program gas:in wd:Q2831984 . # one or more times, specifies the initial frontier.
gas:program gas:target wd:Q7725634 . # only retain vertices along paths to these target vertices.
gas:program gas:out ?out . # exactly once - will be bound to the visited vertices.
gas:program gas:out1 ?depth . # exactly once - will be bound to the depth of the visited vertices.
gas:program gas:out2 ?predecessor . # exactly once - will be bound to the predecessor.
gas:program gas:maxIterations 16 . # optional limit on breadth first expansion.
gas:program gas:maxVisited 2000 . # optional limit on the #of visited vertices.
}
?predecessor wdt:P279 ?out . # figure out what link type(s) connect a vertex with a predecessor
FILTER(STRSTARTS(STR(?predecessor), "http://www.wikidata.org/entity/Q"))
SERVICE wikibase:label { bd:serviceParam wikibase:language "es,en". }
}
order by desc(?depth)
limit 100
Query found at
- https://www.wikidata.org/wiki/User:Tsaorin/Obrasliterarias
- https://www.wikidata.org/wiki/User:Tsaorin/Subclases
- https://www.wikidata.org/wiki/User:Tsaorin/TallerUSAL2020