query-9235597788f0c5eb3088f42dd5f86d9b
PS: I have also tried extracting the subject entity for a more readable query but then the query goes in timeout:
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#>
#defaultView:Graph
SELECT ?superClass ?rgb ?parent ?superClassLabel ?parentLabel
WHERE {
bind (wd:Q1001 as ?item).
{
bind ('FF0000' as ?rgb).
bind (?item as ?superClass). # I suspect this line is causing the timeout, but I don't know the appropriate alternative
?superClass wdt:P31 ?parent.
} UNION {
bind ('FFFFFF' as ?rgb).
?item wdt:P31 ?class.
?class wdt:P279* ?superClass.
?superClass wdt:P279 ?parent.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "it,en,[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?class")
v1("?item")
v4("?parent"):::projected
v5("?rgb"):::projected
v3("?superClass"):::projected
c4(["bd:serviceParam"]):::iri
c6(["it,en,#91;AUTO_LANGUAGE#93;,en"]):::literal
bind0[/"'wd:Q1001'"/]
bind0 --as--o v1
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
bind1[/"'FFFFFF'"/]
bind1 --as--o v5
v1 --"wdt:P31"--> v5
v5 --"wdt:P279"--> v3
v3 --"wdt:P279"--> v4
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
bind2[/"'FF0000'"/]
bind2 --as--o v5
bind3[/"?item"/]
v1 --o bind3
bind3 --as--o v3
v3 --"wdt:P31"--> v4
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c4 --"wikibase:language"--> c6
end