query-56c19ddb502a27ab60f004993219b1c5

rq turtle/ttl

(40) Graph of extended blood relatives by single-headed arrows: Jia BaoyuNo.40 (2020.07.15T0837 created)

Use at

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#>
# find Jia Baoyu's extended blood relatives, i.e., those whose descendant's ancestor's descendant's... share a common ancestor with Jia Baoyu
### Note: In comparison with the previous query "Graph of gene pool (extended blood relatives) by only parent/child relation (no siblings): Jia Baoyu",
### this query only shows parent (father/mother), not including child, on graph edge, so that the arrows are single headed, not double headed,
### as those in the parent section "Graph of extended parent/child countries: the Qin dynasty" (actually having an extended-blood-relatives structure),
### and therefore the graph can present correct generations in a hierarchical layout.
#defaultView:Graph
SELECT ?relative ?relativeLabel ?birthdate ?image ?parent ?parentLabel ?edgeLabel
WHERE {
  # define ?relative as Jia Baoyu (Q8428650)'s any father (P22) or mother (P25) or child (P40)'s father or mother or child's...
  wd:Q8428650 (wdt:P22|wdt:P25|wdt:P40)* ?relative
  # optional: define ?relative's father (P22) or mother (P25) as ?parent
  optional {?relative (wdt:P22|wdt:P25) ?parent
            # To avoid showing any other relation,
            # define ?relation as father (P22) or mother (P25)
            VALUES ?relation {wdt:P22 wdt:P25}
            # ?relation is from ?relative to ?parent
            ?relative ?relation ?parent.
            # get ?relation's property label and allow it to appear on graph edge
            ?edge wikibase:directClaim ?relation;
               a wikibase:Property}
  # optional: show ?relative's birthdate (P569), which only appears in table, not graph
  optional {?relative wdt:P569 ?birthdate}
  # optional: show ?relative's image (P18), which appears directly in graph, and as link in table
  optional {?relative wdt:P18 ?image}
  # show label in auto language as default, and English when no default label exists
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?birthdate"):::projected v4("?edge") v6("?image"):::projected v2("?parent"):::projected v3("?relation") v1("?relative"):::projected c7(["wikibase:Property"]):::iri c1(["wd:Q8428650"]):::iri c11(["bd:serviceParam"]):::iri c13(["#91;AUTO_LANGUAGE#93;,en"]):::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; c1 --"wdt:P40"--> v1 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; c1 --"wdt:P25"--> v1 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; c1 --"wdt:P22"--> v1 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; v1 -."wdt:P25".-> v2 end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P22"--> v2 end union2r <== or ==> union2l end bind0[/VALUES ?relation/] bind0-->v3 bind00(["wdt:P22"]) bind00 --> bind0 bind01(["wdt:P25"]) bind01 --> bind0 v1 -->v3--> v2 v4 --"wikibase:directClaim"--> v3 v4 --"a"--> c7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P569".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P18".-> v6 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end