query-053904522cecb83945e632284a21dea3

rq turtle/ttl

(5) Graph of extended nuclear family: Chiang Kai-shekNo.5 (2019.11.06T0248 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 Chiang Kai-shek's extended nuclear family members, i.e.,
# nuclear family members' nuclear family members'...
#defaultView:Graph
SELECT ?extended_family ?extended_familyLabel ?birthdate ?image ?nuclear_family ?nuclear_familyLabel ?edgeLabel
WHERE {
  # define Chiang Kai-shek (Q16574)'s ?extended_family as
  # any father (P22) or mother (P25) or sibling (P3373) or spouse (P26) or child (P40)'s, i.e., nuclear family member's
  # father or mother or sibling or spouse or child's..., i.e., nuclear family member's...
  wd:Q16574 (wdt:P22|wdt:P25|wdt:P3373|wdt:P26|wdt:P40)* ?extended_family
  ### Note: Persons (vertexes) in a complete graph have stronger connections (edges) than those in noncomplete graph, and
  ### relations (edges) connecting nuclear family members (vertexes, at least 3: two spouses and one child) form a complete graph.
  ### A complete graph with at least 3 vertexes is usually a nuclear family or part of nuclear family 
  ### although it may not always be the case
  ### (e.g., a husband has two wives who are sisters of each other, or
  ### a man's wife is his son's daughter).
  # optional: define ?extended_family's father (P22) or mother (P25) or sibling (P3373) or spouse (P26) or child (P40),
  # i.e., nuclear family member, as ?nuclear_family
  optional {?extended_family (wdt:P22|wdt:P25|wdt:P3373|wdt:P26|wdt:P40) ?nuclear_family
            # To avoid showing any other relation than nuclear-family relation
            # define ?relation as only father (P22) or mother (P25) or sibling (P3373) or spouse (P26) or child (P40)
            VALUES ?relation {wdt:P22 wdt:P25 wdt:P3373 wdt:P26 wdt:P40}
            # ?relation is from ?extended_family to ?nuclear_family
            ?extended_family ?relation ?nuclear_family.
            # show ?relation on graph edges
            ?edge wikibase:directClaim ?relation;
               a wikibase:Property}
  # optional: show ?extended_family's birthdate (P569), which only appears in table, not graph 
  optional {?extended_family wdt:P569 ?birthdate}
  # optional: show ?extended_family's image (P18), which appears directly in graph, and as link in table
  optional {?extended_family wdt:P18 ?image}
  # show label in simplified Chinese (zh-hans) as default, and English when no default label exists
  SERVICE wikibase:label { bd:serviceParam wikibase:language "zh-hans,en". } 
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?birthdate"):::projected v4("?edge") v1("?extended_family"):::projected v6("?image"):::projected v2("?nuclear_family"):::projected v3("?relation") c9(["wikibase:Property"]):::iri c15(["zh-hans,en"]):::literal c13(["bd:serviceParam"]):::iri c1(["wd:Q16574"]):::iri 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; subgraph union2[" Union "] subgraph union2l[" "] style union2l fill:#abf,stroke-dasharray: 3 3; subgraph union3[" Union "] subgraph union3l[" "] style union3l fill:#abf,stroke-dasharray: 3 3; c1 --"wdt:P40"--> v1 end subgraph union3r[" "] style union3r fill:#abf,stroke-dasharray: 3 3; c1 --"wdt:P26"--> v1 end union3r <== or ==> union3l end end subgraph union2r[" "] style union2r fill:#abf,stroke-dasharray: 3 3; c1 --"wdt:P3373"--> v1 end union2r <== or ==> union2l end 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 union4[" Union "] subgraph union4l[" "] style union4l fill:#abf,stroke-dasharray: 3 3; subgraph union5[" Union "] subgraph union5l[" "] style union5l fill:#abf,stroke-dasharray: 3 3; subgraph union6[" Union "] subgraph union6l[" "] style union6l fill:#abf,stroke-dasharray: 3 3; subgraph union7[" Union "] subgraph union7l[" "] style union7l fill:#abf,stroke-dasharray: 3 3; v1 -."wdt:P40".-> v2 end subgraph union7r[" "] style union7r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P26"--> v2 end union7r <== or ==> union7l end end subgraph union6r[" "] style union6r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P3373"--> v2 end union6r <== or ==> union6l end end subgraph union5r[" "] style union5r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P25"--> v2 end union5r <== or ==> union5l end end subgraph union4r[" "] style union4r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P22"--> v2 end union4r <== or ==> union4l end bind0[/VALUES ?relation/] bind0-->v3 bind00(["wdt:P22"]) bind00 --> bind0 bind01(["wdt:P25"]) bind01 --> bind0 bind02(["wdt:P3373"]) bind02 --> bind0 bind03(["wdt:P26"]) bind03 --> bind0 bind04(["wdt:P40"]) bind04 --> bind0 v1 -->v3--> v2 v4 --"wikibase:directClaim"--> v3 v4 --"a"--> c9 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; c13 --"wikibase:language"--> c15 end