Skip to content

Instantly share code, notes, and snippets.

@cleishm
Forked from frant-hartm/graph-royalty.adoc
Last active December 27, 2015 11:29

Revisions

  1. cleishm revised this gist Nov 5, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions graph-royalty.adoc
    Original file line number Diff line number Diff line change
    @@ -139,7 +139,7 @@ This query will get all successors on the throne
    ----
    match (anne)<-[:SUCCEEDED*0..]-(suc)
    where anne.name="Anne"
    return suc
    return suc.name
    ----

    == Predecessor
    @@ -151,7 +151,7 @@ This retrieves just one predecessor.
    ----
    match (g)-[:SUCCEEDED]->(pre)
    where g.name="George II"
    return pre
    return pre.name
    ----

    = Improvements
  2. cleishm revised this gist Nov 5, 2013. 1 changed file with 48 additions and 51 deletions.
    99 changes: 48 additions & 51 deletions graph-royalty.adoc
    Original file line number Diff line number Diff line change
    @@ -38,59 +38,59 @@ create (georgeIII {name:"George III"})
    create (frederickWales {name:"Frederick"})
    create (carolineMatilda {name:"Caroline Matilda"})
    create georgeII-[:HAD_SON]->frederickWales
    create frederickWales-[:HAD_SON]->georgeIII
    create frederickWales-[:HAD_DAUGHTER]->carolineMatilda
    create (georgeII)-[:HAD_SON]->(frederickWales)
    create (frederickWales)-[:HAD_SON]->(georgeIII)
    create (frederickWales)-[:HAD_DAUGHTER]->(carolineMatilda)
    create anne-[:MEMBER_OF]->houseOfSstuart
    create anne-[:REIGNED]->britain
    create (anne)-[:MEMBER_OF]->(houseOfSstuart)
    create (anne)-[:REIGNED]->(britain)
    create georgeI-[:MEMBER_OF]->houseOfHanover
    create georgeI-[:SUCCEEDED]->anne
    create georgeI-[:REIGNED]->britain
    create (georgeI)-[:MEMBER_OF]->(houseOfHanover)
    create (georgeI)-[:SUCCEEDED]->(anne)
    create (georgeI)-[:REIGNED]->(britain)
    create georgeII-[:MEMBER_OF]->houseOfHanover
    create georgeII-[:SUCCEEDED]->georgeI
    create georgeII-[:REIGNED]->britain
    create georgeII-[:REIGNED]->hanover
    create (georgeII)-[:MEMBER_OF]->(houseOfHanover)
    create (georgeII)-[:SUCCEEDED]->(georgeI)
    create (georgeII)-[:REIGNED]->(britain)
    create (georgeII)-[:REIGNED]->(hanover)
    create georgeIII-[:MEMBER_OF]->houseOfHanover
    create georgeIII-[:SUCCEEDED]->georgeII
    create georgeIII-[:REIGNED]->britain
    create georgeIII-[:REIGNED]->hanover
    create (georgeIII)-[:MEMBER_OF]->(houseOfHanover)
    create (georgeIII)-[:SUCCEEDED]->(georgeII)
    create (georgeIII)-[:REIGNED]->(britain)
    create (georgeIII)-[:REIGNED]->(hanover)
    create (frederickIV {name:"Frederick IV"})
    create (christianVI {name:"Christian VI"})
    create (frederickV {name:"Frederick V"})
    create (christianVII {name:"Christian VII"})
    create frederickIV-[:MEMBER_OF]->houseOfOldenburg
    create frederickIV-[:REIGNED]->denmark
    create (frederickIV)-[:MEMBER_OF]->(houseOfOldenburg)
    create (frederickIV)-[:REIGNED]->(denmark)
    create christianVI-[:MEMBER_OF]->houseOfOldenburg
    create christianVI-[:REIGNED]->denmark
    create christianVI-[:SUCCEEDED]->frederickIV
    create (christianVI)-[:MEMBER_OF]->(houseOfOldenburg)
    create (christianVI)-[:REIGNED]->(denmark)
    create (christianVI)-[:SUCCEEDED]->(frederickIV)
    create frederickV-[:MEMBER_OF]->houseOfOldenburg
    create frederickV-[:REIGNED]->denmark
    create frederickV-[:SUCCEEDED]->christianVI
    create (frederickV)-[:MEMBER_OF]->(houseOfOldenburg)
    create (frederickV)-[:REIGNED]->(denmark)
    create (frederickV)-[:SUCCEEDED]->(christianVI)
    create christianVII-[:MEMBER_OF]->houseOfOldenburg
    create christianVII-[:REIGNED]->denmark
    create christianVII-[:SUCCEEDED]->frederickV
    create (christianVII)-[:MEMBER_OF]->(houseOfOldenburg)
    create (christianVII)-[:REIGNED]->(denmark)
    create (christianVII)-[:SUCCEEDED]->(frederickV)
    create christianVII-[:MARRIED]-carolineMatilda
    create (christianVII)-[:MARRIED]->(carolineMatilda)
    create (louise {name:"Louise of Great Britain"})
    create georgeII-[:HAD_DAUGHTER]->louise
    create frederickV-[:MARRIED]-louise
    create (georgeII)-[:HAD_DAUGHTER]->(louise)
    create (frederickV)-[:MARRIED]->(louise)
    create (sophia {name: "Sophia Magdalena"})
    create louise-[:HAD_DAUGHTER]->sophia
    create frederickV-[:HAD_DAUGHTER]->sophia
    create (louise)-[:HAD_DAUGHTER]->(sophia)
    create (frederickV)-[:HAD_DAUGHTER]->(sophia)
    create (charlesII {name:"Charles XII"})
    create (ulrika {name:"Ulrika Eleonora"})
    @@ -99,20 +99,20 @@ create (adolfF {name:"Adolf Frederick"})
    create (gustavIII {name:"Gustav_III_of_Sweden"})
    create (gustavIV {name:"Gustav IV Adolf"})
    create charlesII<-[:SUCEEDED]-ulrika
    create ulrika<-[:SUCEEDED]-frederick
    create frederick<-[:SUCEEDED]-adolfF
    create adolfF<-[:SUCEEDED]-gustavIII
    create gustavIII<-[:SUCEEDED]-gustavIV
    create (charlesII)<-[:SUCEEDED]-(ulrika)
    create (ulrika)<-[:SUCEEDED]-(frederick)
    create (frederick)<-[:SUCEEDED]-(adolfF)
    create (adolfF)<-[:SUCEEDED]-(gustavIII)
    create (gustavIII)<-[:SUCEEDED]-(gustavIV)
    create charlesII-[:REIGNED]->sweden
    create ulrika-[:REIGNED]->sweden
    create frederick-[:REIGNED]->sweden
    create adolfF-[:REIGNED]->sweden
    create gustavIII-[:REIGNED]->sweden
    create gustavIV-[:REIGNED]->sweden
    create (charlesII)-[:REIGNED]->(sweden)
    create (ulrika)-[:REIGNED]->(sweden)
    create (frederick)-[:REIGNED]->(sweden)
    create (adolfF)-[:REIGNED]->(sweden)
    create (gustavIII)-[:REIGNED]->(sweden)
    create (gustavIV)-[:REIGNED]->(sweden)
    create gustavIII-[:MARRIED]-sophia
    create (gustavIII)-[:MARRIED]->(sophia)
    ----
    @@ -122,8 +122,7 @@ create gustavIII-[:MARRIED]-sophia
    How were the countries related through royal families?
    [source,cypher]
    ----
    START c1=node(*),c2=node(*)
    MATCH path =(c1<-[:REIGNED]-r1-[:HAD_DAUGHTER|MARRIED*0..]-r2-[:REIGNED]->c2)
    MATCH path =((c1)<-[:REIGNED]-(r1)-[:HAD_DAUGHTER|MARRIED*0..]-(r2)-[:REIGNED]->(c2))
    WHERE c1.name="Great Britain" AND c2.name = 'Denmark and Norway'
    RETURN path
    ----
    @@ -138,8 +137,7 @@ This query will get all successors on the throne
    //output
    [source,cypher]
    ----
    start anne=node(*)
    match anne<-[:SUCCEEDED*0..]-suc
    match (anne)<-[:SUCCEEDED*0..]-(suc)
    where anne.name="Anne"
    return suc
    ----
    @@ -151,13 +149,12 @@ This retrieves just one predecessor.
    //output
    [source,cypher]
    ----
    start g=node(*)
    match g-[:SUCCEEDED]->pre
    match (g)-[:SUCCEEDED]->(pre)
    where g.name="George II"
    return pre
    ----

    = Improvements

    * index names for better performance
    * crawl wikipedia (or wikidata) to get comprehensive database
    * crawl wikipedia (or wikidata) to get comprehensive database
  3. @frant-hartm frant-hartm renamed this gist Sep 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graph-gist.adoc → graph-royalty.adoc
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    = European Royalty in 18th century
    = Royalty in Europe

    The Royal families generaly have long histories and are often closely related. This link:http://en.wikipedia.org/wiki/Nicholas_II_of_Russia[citation from wikipedia] can give you better idea:

  4. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,8 @@ The Royal families generaly have long histories and are often closely related. T

    [quote]
    Maternally, Nicholas was the nephew of several monarchs, including King Frederick VIII of Denmark, Queen Alexandra of the United Kingdom (queen consort of King Edward VII), and King George I of Greece. Nicholas, his wife, Alexandra, and Kaiser Wilhelm II of Germany were all first cousins of King George V of the United Kingdom. Nicholas was also a first cousin of both King Haakon VII and Queen Maud of Norway, as well as King Constantine I of Greece. While not first cousins, Nicholas and Kaiser Wilhelm II were second cousins, once removed, as each descended from King Frederick William III of Prussia, as well as third cousins, as they were both great-great-grandsons of Emperor Paul I of Russia.
    ----

    The rulers of Great Britain, Germany and Russia were actually cousins.
    The rulers of Great Britain, Germany and Russia at the beginning of World War I were actually cousins!

    == Model

  5. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    = European Royalty in 18th century

    The Royal families generaly have long histories and are often closely related. This citation from wikipedia can give you better idea:
    The Royal families generaly have long histories and are often closely related. This link:http://en.wikipedia.org/wiki/Nicholas_II_of_Russia[citation from wikipedia] can give you better idea:

    [quote]
    Maternally, Nicholas was the nephew of several monarchs, including King Frederick VIII of Denmark, Queen Alexandra of the United Kingdom (queen consort of King Edward VII), and King George I of Greece. Nicholas, his wife, Alexandra, and Kaiser Wilhelm II of Germany were all first cousins of King George V of the United Kingdom. Nicholas was also a first cousin of both King Haakon VII and Queen Maud of Norway, as well as King Constantine I of Greece. While not first cousins, Nicholas and Kaiser Wilhelm II were second cousins, once removed, as each descended from King Frederick William III of Prussia, as well as third cousins, as they were both great-great-grandsons of Emperor Paul I of Russia.
    [quote]
    ----

    The rulers of Great Britain, Germany and Russia were actually cousins.

  6. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 25 additions and 15 deletions.
    40 changes: 25 additions & 15 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,21 @@
    = European Royalty in 18th century =
    = European Royalty in 18th century

    The Royal families generaly have long histories and are often closely related.
    The Royal families generaly have long histories and are often closely related. This citation from wikipedia can give you better idea:

    [quote]
    Maternally, Nicholas was the nephew of several monarchs, including King Frederick VIII of Denmark, Queen Alexandra of the United Kingdom (queen consort of King Edward VII), and King George I of Greece. Nicholas, his wife, Alexandra, and Kaiser Wilhelm II of Germany were all first cousins of King George V of the United Kingdom. Nicholas was also a first cousin of both King Haakon VII and Queen Maud of Norway, as well as King Constantine I of Greece. While not first cousins, Nicholas and Kaiser Wilhelm II were second cousins, once removed, as each descended from King Frederick William III of Prussia, as well as third cousins, as they were both great-great-grandsons of Emperor Paul I of Russia.
    [quote]

    The rulers of Great Britain, Germany and Russia were actually cousins.

    == Model

    Simple family relationships may be represented by following model

    image::https://docs.google.com/drawings/d/1iJxIliqLzj9-LWVtj1bZorr90Ulr5s3H_fACQpi2ImQ/pub?w=960&amp;h=720[Model]

    == Sample data
    Let's add some sample data. This is far from complete but it allows to demonstrate the main point.
    This sample data set is far from complete but it allows to demonstrate the main point. It contains monarch of Great Britain, Sweden, Denmark and Norway in 18th century.

    //hide
    //setup
    @@ -114,6 +118,21 @@ create gustavIII-[:MARRIED]-sophia
    ----

    == Country relations

    How were the countries related through royal families?
    [source,cypher]
    ----
    START c1=node(*),c2=node(*)
    MATCH path =(c1<-[:REIGNED]-r1-[:HAD_DAUGHTER|MARRIED*0..]-r2-[:REIGNED]->c2)
    WHERE c1.name="Great Britain" AND c2.name = 'Denmark and Norway'
    RETURN path
    ----

    //graph

    There are also other posibilities to query.

    == Successors

    This query will get all successors on the throne
    @@ -139,16 +158,7 @@ where g.name="George II"
    return pre
    ----

    = Improvements

    == Country relations

    How were the countries related through royal families?
    [source,cypher]
    ----
    START c1=node(*),c2=node(*)
    MATCH path =(c1<-[:REIGNED]-r1-[:HAD_DAUGHTER|MARRIED*0..]-r2-[:REIGNED]->c2)
    WHERE c1.name="Great Britain" AND c2.name = 'Denmark and Norway'
    RETURN path
    ----

    //graph
    * index names for better performance
    * crawl wikipedia (or wikidata) to get comprehensive database
  7. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    = European Royalty in 18th century =

    The Royal families generaly have long histories and are often closely related.

    [quote]
    Maternally, Nicholas was the nephew of several monarchs, including King Frederick VIII of Denmark, Queen Alexandra of the United Kingdom (queen consort of King Edward VII), and King George I of Greece. Nicholas, his wife, Alexandra, and Kaiser Wilhelm II of Germany were all first cousins of King George V of the United Kingdom. Nicholas was also a first cousin of both King Haakon VII and Queen Maud of Norway, as well as King Constantine I of Greece. While not first cousins, Nicholas and Kaiser Wilhelm II were second cousins, once removed, as each descended from King Frederick William III of Prussia, as well as third cousins, as they were both great-great-grandsons of Emperor Paul I of Russia.
    [quote]

    == Model

    image::https://docs.google.com/drawings/d/1iJxIliqLzj9-LWVtj1bZorr90Ulr5s3H_fACQpi2ImQ/pub?w=960&amp;h=720[Model]
  8. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    == Model

    image: https://docs.google.com/drawings/d/1iJxIliqLzj9-LWVtj1bZorr90Ulr5s3H_fACQpi2ImQ/pub?w=960&amp;h=720
    image::https://docs.google.com/drawings/d/1iJxIliqLzj9-LWVtj1bZorr90Ulr5s3H_fACQpi2ImQ/pub?w=960&amp;h=720[Model]

    == Sample data
    Let's add some sample data. This is far from complete but it allows to demonstrate the main point.
  9. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    == Model

    image:https://docs.google.com/drawings/d/1iJxIliqLzj9-LWVtj1bZorr90Ulr5s3H_fACQpi2ImQ/pub?w=960&amp;h=720
    image: https://docs.google.com/drawings/d/1iJxIliqLzj9-LWVtj1bZorr90Ulr5s3H_fACQpi2ImQ/pub?w=960&amp;h=720

    == Sample data
    Let's add some sample data. This is far from complete but it allows to demonstrate the main point.
  10. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,9 @@
    = European Royalty in 18th century =

    == Model

    image:https://docs.google.com/drawings/d/1iJxIliqLzj9-LWVtj1bZorr90Ulr5s3H_fACQpi2ImQ/pub?w=960&amp;h=720

    == Sample data
    Let's add some sample data. This is far from complete but it allows to demonstrate the main point.

  11. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -94,12 +94,12 @@ create gustavIII<-[:SUCEEDED]-gustavIV
    create charlesII-[:REIGNED]->sweden
    create ulrika-[:REIGNED]->sweden
    create frederik-[:REIGNED]->sweden
    create frederick-[:REIGNED]->sweden
    create adolfF-[:REIGNED]->sweden
    create gustavIII-[:REIGNED]->sweden
    create gustavIV-[:REIGNED]->sweden
    create gustavIII-[:MARRIED]-sofia
    create gustavIII-[:MARRIED]-sophia
    ----
  12. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -75,7 +75,7 @@ create (louise {name:"Louise of Great Britain"})
    create georgeII-[:HAD_DAUGHTER]->louise
    create frederickV-[:MARRIED]-louise
    create (sophia {name: "Sophia Magdalena of Denmark"})
    create (sophia {name: "Sophia Magdalena"})
    create louise-[:HAD_DAUGHTER]->sophia
    create frederickV-[:HAD_DAUGHTER]->sophia
    @@ -86,7 +86,11 @@ create (adolfF {name:"Adolf Frederick"})
    create (gustavIII {name:"Gustav_III_of_Sweden"})
    create (gustavIV {name:"Gustav IV Adolf"})
    create charlesII<-[:SUCEEDED]-ulrika<-[:SUCEEDED]-frederick<-[:SUCEEDED]-adolfF<-[:SUCEEDED]-gustavIII<-[:SUCEEDED]-gustavIV
    create charlesII<-[:SUCEEDED]-ulrika
    create ulrika<-[:SUCEEDED]-frederick
    create frederick<-[:SUCEEDED]-adolfF
    create adolfF<-[:SUCEEDED]-gustavIII
    create gustavIII<-[:SUCEEDED]-gustavIV
    create charlesII-[:REIGNED]->sweden
    create ulrika-[:REIGNED]->sweden
  13. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -137,6 +137,4 @@ WHERE c1.name="Great Britain" AND c2.name = 'Denmark and Norway'
    RETURN path
    ----

    //graph1

    //console
    //graph
  14. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -25,8 +25,8 @@ create (georgeIII {name:"George III"})
    create (frederickWales {name:"Frederick"})
    create (carolineMatilda {name:"Caroline Matilda"})
    create georgeII-[:HAD_SON}->frederickWales
    create frederickWales-[:HAD_SON}->georgeIII
    create georgeII-[:HAD_SON]->frederickWales
    create frederickWales-[:HAD_SON]->georgeIII
    create frederickWales-[:HAD_DAUGHTER]->carolineMatilda
    create anne-[:MEMBER_OF]->houseOfSstuart
  15. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -16,11 +16,19 @@ create (houseOfSstuart {name:"House of Stuart"})
    create (houseOfHanover {name:"House of Hanover"})
    create (houseOfOldenburg {name: "House of Oldenburg"})
    create (anne {name:"Anne"})
    create (georgeI {name:"George I"})
    create (georgeII {name:"George II"})
    create (georgeIII {name:"George III"})
    create (frederickWales {name:"Frederick"})
    create (carolineMatilda {name:"Caroline Matilda"})
    create georgeII-[:HAD_SON}->frederickWales
    create frederickWales-[:HAD_SON}->georgeIII
    create frederickWales-[:HAD_DAUGHTER]->carolineMatilda
    create anne-[:MEMBER_OF]->houseOfSstuart
    create anne-[:REIGNED]->britain
    @@ -60,13 +68,16 @@ create christianVII-[:MEMBER_OF]->houseOfOldenburg
    create christianVII-[:REIGNED]->denmark
    create christianVII-[:SUCCEEDED]->frederickV
    create christianVII-[:MARRIED]-carolineMatilda
    create (louise {name:"Louise of Great Britain"})
    create georgeII-[:HAD_DAUGHTER]->louise
    create frederickV-[:MARRIED]-louise
    create (sophia {name: "Sophia Magdalena of Denmark"})
    create louise-[:HAD_DAUGHTER]->sophia
    create frederickV-[:HAD_DAUGHTER]-sophia
    create frederickV-[:HAD_DAUGHTER]->sophia
    create (charlesII {name:"Charles XII"})
    create (ulrika {name:"Ulrika Eleonora"})
    @@ -84,6 +95,8 @@ create adolfF-[:REIGNED]->sweden
    create gustavIII-[:REIGNED]->sweden
    create gustavIV-[:REIGNED]->sweden
    create gustavIII-[:MARRIED]-sofia
    ----

  16. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -69,7 +69,7 @@ create louise-[:HAD_DAUGHTER]->sophia
    create frederickV-[:HAD_DAUGHTER]-sophia
    create (charlesII {name:"Charles XII"})
    craete (ulrika {name:"Ulrika Eleonora"})
    create (ulrika {name:"Ulrika Eleonora"})
    create (frederick {name:"Frederick I"})
    create (adolfF {name:"Adolf Frederick"})
    create (gustavIII {name:"Gustav_III_of_Sweden"})
  17. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 24 additions and 2 deletions.
    26 changes: 24 additions & 2 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@ Let's add some sample data. This is far from complete but it allows to demonstra
    create (britain {name:"Great Britain"})
    create (hanover {name:"Hanover"})
    create (denmark {name:"Denmark and Norway"})
    create (sweden {name:"Sweden"})
    create (houseOfSstuart {name:"House of Stuart"})
    create (houseOfHanover {name:"House of Hanover"})
    @@ -60,9 +61,30 @@ create christianVII-[:REIGNED]->denmark
    create christianVII-[:SUCCEEDED]->frederickV
    create (louise {name:"Louise of Great Britain"})
    create georgeII-[:HAS_DAUGHTER]->louise
    create georgeII-[:HAD_DAUGHTER]->louise
    create frederickV-[:MARRIED]-louise
    create (sophia {name: "Sophia Magdalena of Denmark"})
    create louise-[:HAD_DAUGHTER]->sophia
    create frederickV-[:HAD_DAUGHTER]-sophia
    create (charlesII {name:"Charles XII"})
    craete (ulrika {name:"Ulrika Eleonora"})
    create (frederick {name:"Frederick I"})
    create (adolfF {name:"Adolf Frederick"})
    create (gustavIII {name:"Gustav_III_of_Sweden"})
    create (gustavIV {name:"Gustav IV Adolf"})
    create charlesII<-[:SUCEEDED]-ulrika<-[:SUCEEDED]-frederick<-[:SUCEEDED]-adolfF<-[:SUCEEDED]-gustavIII<-[:SUCEEDED]-gustavIV
    create charlesII-[:REIGNED]->sweden
    create ulrika-[:REIGNED]->sweden
    create frederik-[:REIGNED]->sweden
    create adolfF-[:REIGNED]->sweden
    create gustavIII-[:REIGNED]->sweden
    create gustavIV-[:REIGNED]->sweden
    ----

    == Successors
    @@ -97,7 +119,7 @@ How were the countries related through royal families?
    [source,cypher]
    ----
    START c1=node(*),c2=node(*)
    MATCH path =(c1<-[:REIGNED]-r1-[:HAS_DAUGHTER|MARRIED*0..]-r2-[:REIGNED]->c2)
    MATCH path =(c1<-[:REIGNED]-r1-[:HAD_DAUGHTER|MARRIED*0..]-r2-[:REIGNED]->c2)
    WHERE c1.name="Great Britain" AND c2.name = 'Denmark and Norway'
    RETURN path
    ----
  18. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -96,10 +96,10 @@ return pre
    How were the countries related through royal families?
    [source,cypher]
    ----
    start c1=node(*),c2=node(*)
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER|MARRIED*0..]-r2-[:REIGNED]->c2
    where c1.name="Great Britain" AND c2.name = "Denmark and Norway"
    return c1,c2
    START c1=node(*),c2=node(*)
    MATCH path =(c1<-[:REIGNED]-r1-[:HAS_DAUGHTER|MARRIED*0..]-r2-[:REIGNED]->c2)
    WHERE c1.name="Great Britain" AND c2.name = 'Denmark and Norway'
    RETURN path
    ----

    //graph1
  19. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -100,7 +100,7 @@ start c1=node(*),c2=node(*)
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER|MARRIED*0..]-r2-[:REIGNED]->c2
    where c1.name="Great Britain" AND c2.name = "Denmark and Norway"
    return c1,c2
    ----

    //graph1

  20. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -97,7 +97,7 @@ How were the countries related through royal families?
    [source,cypher]
    ----
    start c1=node(*),c2=node(*)
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER*0|:MARRIED*0..]-r2-[:REIGNED]->c2
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER|MARRIED*0..]-r2-[:REIGNED]->c2
    where c1.name="Great Britain" AND c2.name = "Denmark and Norway"
    return c1,c2
  21. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -97,7 +97,7 @@ How were the countries related through royal families?
    [source,cypher]
    ----
    start c1=node(*),c2=node(*)
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER*0..,:MARRIED*0..]-r2-[:REIGNED]->c2
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER*0|:MARRIED*0..]-r2-[:REIGNED]->c2
    where c1.name="Great Britain" AND c2.name = "Denmark and Norway"
    return c1,c2
  22. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -97,7 +97,7 @@ How were the countries related through royal families?
    [source,cypher]
    ----
    start c1=node(*),c2=node(*)
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER,:MARRIED*0..]-r2-[:REIGNED]->c2
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER*0..,:MARRIED*0..]-r2-[:REIGNED]->c2
    where c1.name="Great Britain" AND c2.name = "Denmark and Norway"
    return c1,c2
  23. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -97,9 +97,9 @@ How were the countries related through royal families?
    [source,cypher]
    ----
    start c1=node(*),c2=node(*)
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER,MARRIED*0..]-r2-[:REIGNED]->c2
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER,:MARRIED*0..]-r2-[:REIGNED]->c2
    where c1.name="Great Britain" AND c2.name = "Denmark and Norway"
    return pre
    return c1,c2
    //graph1
  24. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -91,6 +91,17 @@ return pre
    ----


    == Country relations

    How were the countries related through royal families?
    [source,cypher]
    ----
    start c1=node(*),c2=node(*)
    match c1<-[:REIGNED]-r1-[:HAS_DAUGHTER,MARRIED*0..]-r2-[:REIGNED]->c2
    where c1.name="Great Britain" AND c2.name = "Denmark and Norway"
    return pre
    //graph1
    //console
  25. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -59,6 +59,9 @@ create christianVII-[:MEMBER_OF]->houseOfOldenburg
    create christianVII-[:REIGNED]->denmark
    create christianVII-[:SUCCEEDED]->frederickV
    create (louise {name:"Louise of Great Britain"})
    create georgeII-[:HAS_DAUGHTER]->louise
    create frederickV-[:MARRIED]-louise
    ----

  26. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -40,7 +40,7 @@ create georgeIII-[:REIGNED]->hanover
    create (frederickIV {name:"Frederick IV"})
    create (christianVI {name:"Christian VI"})
    create (frederickV {name:"Frederick V"}
    create (frederickV {name:"Frederick V"})
    create (christianVII {name:"Christian VII"})
    create frederickIV-[:MEMBER_OF]->houseOfOldenburg
  27. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,7 @@ create georgeIII-[:REIGNED]->hanover
    create (frederickIV {name:"Frederick IV"})
    create (christianVI {name:Christian VI"})
    create (christianVI {name:"Christian VI"})
    create (frederickV {name:"Frederick V"}
    create (christianVII {name:"Christian VII"})
  28. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 26 additions and 23 deletions.
    49 changes: 26 additions & 23 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -7,55 +7,58 @@ Let's add some sample data. This is far from complete but it allows to demonstra
    //setup
    [source,cypher]
    ----
    create (england {name:"England"})
    create (scotland {name:"Scotland"})
    create (britain {name:"Great Britain"})
    create (ireland {name:"Ireland"})
    create (hanover {name:"Hanover"})
    create (france {name:"France"})
    create (russia {name:"Russia"})
    create (c17th {name:"17th century"})
    create (c18th {name:"18th century"})
    create (c19th {name:"19th century"})
    create (denmark {name:"Denmark and Norway"})
    create (houseOfSstuart {name:"House of Stuart"})
    create (houseOfHanover {name:"House of Hanover"})
    create (houseOfOldenburg {name: "House of Oldenburg"})
    create (anne {name:"Anne"})
    create (georgeI {name:"George I"})
    create (georgeII {name:"George II"})
    create (georgeIII {name:"George III"})
    create anne-[:MEMBER_OF]->houseOfSstuart
    create anne-[:REIGNED]->england
    create anne-[:REIGNED]->scotland
    create anne-[:REIGNED]->ireland
    create anne-[:LIVED_IN]->c17th
    create anne-[:LIVED_IN]->c18th
    create anne-[:REIGNED]->britain
    create georgeI-[:MEMBER_OF]->houseOfHanover
    create georgeI-[:SUCCEEDED]->anne
    create georgeI-[:REIGNED]->britain
    create georgeI-[:REIGNED]->ireland
    create georgeI-[:LIVED_IN]->c17th
    create georgeI-[:LIVED_IN]->c18th
    create georgeII-[:MEMBER_OF]->houseOfHanover
    create georgeII-[:SUCCEEDED]->georgeI
    create georgeII-[:REIGNED]->britain
    create georgeII-[:REIGNED]->ireland
    create georgeII-[:REIGNED]->hanover
    create georgeII-[:LIVED_IN]->c17th
    create georgeII-[:LIVED_IN]->c18th
    create georgeIII-[:MEMBER_OF]->houseOfHanover
    create georgeIII-[:SUCCEEDED]->georgeII
    create georgeIII-[:REIGNED]->britain
    create georgeIII-[:REIGNED]->ireland
    create georgeIII-[:REIGNED]->hanover
    create georgeIII-[:LIVED_IN]->c18th
    create georgeIII-[:LIVED_IN]->c19th
    create (frederickIV {name:"Frederick IV"})
    create (christianVI {name:Christian VI"})
    create (frederickV {name:"Frederick V"}
    create (christianVII {name:"Christian VII"})
    create frederickIV-[:MEMBER_OF]->houseOfOldenburg
    create frederickIV-[:REIGNED]->denmark
    create christianVI-[:MEMBER_OF]->houseOfOldenburg
    create christianVI-[:REIGNED]->denmark
    create christianVI-[:SUCCEEDED]->frederickIV
    create frederickV-[:MEMBER_OF]->houseOfOldenburg
    create frederickV-[:REIGNED]->denmark
    create frederickV-[:SUCCEEDED]->christianVI
    create christianVII-[:MEMBER_OF]->houseOfOldenburg
    create christianVII-[:REIGNED]->denmark
    create christianVII-[:SUCCEEDED]->frederickV
    ----

  29. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -66,7 +66,7 @@ This query will get all successors on the throne
    [source,cypher]
    ----
    start anne=node(*)
    match anne<-[SUCCEEDED*0..]-suc
    match anne<-[:SUCCEEDED*0..]-suc
    where anne.name="Anne"
    return suc
    ----
    @@ -79,7 +79,7 @@ This retrieves just one predecessor.
    [source,cypher]
    ----
    start g=node(*)
    match g-[SUCCEEDED*0..]->pre
    match g-[:SUCCEEDED]->pre
    where g.name="George II"
    return pre
    ----
  30. @frant-hartm frant-hartm revised this gist Sep 30, 2013. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions graph-gist.adoc
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    = European Royalty in 18th century =

    == Sample data
    Let's add some sample data. This is far from complete but it allows to demonstrate the main point.

    //hide
    //setup
    [source,cypher]
    @@ -56,6 +59,9 @@ create georgeIII-[:LIVED_IN]->c19th
    ----

    == Successors

    This query will get all successors on the throne
    //output
    [source,cypher]
    ----
    @@ -65,6 +71,20 @@ where anne.name="Anne"
    return suc
    ----

    == Predecessor

    This retrieves just one predecessor.

    //output
    [source,cypher]
    ----
    start g=node(*)
    match g-[SUCCEEDED*0..]->pre
    where g.name="George II"
    return pre
    ----


    //graph1

    //console