maurice1408/Neodash

Is this efficient?

Closed this issue · 1 comments

It is massive but repetitive ...

//
// Villiers, Frances, 4th Countess of Jersey
// Battiscombe, Honor
// Banks, Sir Joseph
// Charlotte, Queen of Great Britain and Ireland and Electress of Hanover
// Stuart, John, 3rd Earl of Bute
// Villiers, Frances, 4th Countess of Jersey (1753-1821) 
// Graham, James
// Hamilton, Sir William
// Fitzroy, Augustus Henry, 3rd Duke of Grafton
// TO 
// George III, King of Great Britain and Ireland (1738-1820) Pair 1
//
OPTIONAL MATCH (p1a:Person), (p1b:Person), (p1c:Person), (p1d:Person), (p1e:Person), (p1f:Person), (p1g:Person), (p1h:Person), (p1i:Person),
r1b = shortestPath((p1b)-[*..3]-(p1a)),
r1c = shortestPath((p1c)-[*..3]-(p1a)),
r1d = shortestPath((p1d)-[*..3]-(p1a)),
r1e = shortestPath((p1e)-[*..3]-(p1a)),
r1f = shortestPath((p1f)-[*..3]-(p1a)),
r1g = shortestPath((p1g)-[*..3]-(p1a)),
r1h = shortestPath((p1h)-[*..3]-(p1a)),
r1i = shortestPath((p1i)-[*..3]-(p1a))
WHERE p1a.name = "George III, King of Great Britain and Ireland" and
p1b.name = "Villiers, Frances, 4th Countess of Jersey" and
p1c.name = "Battiscombe, Honor" and 
p1d.name = "Banks, Sir Joseph" and
p1e.name = "Charlotte, Queen of Great Britain and Ireland and Electress of Hanover" and
p1f.name = "Stuart, John, 3rd Earl of Bute" and
p1g.name = "Graham, James" and
p1h.name = "Hamilton, Sir William" and
p1i.name = "Fitzroy, Augustus Henry, 3rd Duke of Grafton"
//
// Villiers, Frances, 4th Countess of Jersey
// Beauclerk, Lady Diana
// Delany, Mary
// TO 
// Charlotte, Queen of Great Britain and Ireland and Electress of Hanover Pair 1 
//
OPTIONAL MATCH (p1fa:Person), (p1fb:Person), (p1fc:Person), (p1fd:Person),
r1fb = shortestPath((p1fb)-[*..3]-(p1fa)),
r1fc = shortestPath((p1fc)-[*..3]-(p1fa)),
r1fd = shortestPath((p1fd)-[*..3]-(p1fa))
WHERE p1fa.name = "Charlotte, Queen of Great Britain and Ireland and Electress of Hanover" and
p1fb.name = "Villiers, Frances, 4th Countess of Jersey"  and
p1fc.name = "Beauclerk, Lady Diana" and
p1fd.name = "Delany, Mary" 
//
// John Stuart (1713-1792)
// Wortley Montagu, Lady Mary
// Beauclerk, Harriot, 9th Duchess of St Albans (1777-1837)
// TO
// Francis Dashwood (1708-1781) Pair 3 
//
OPTIONAL MATCH (p3a:Person), (p3b:Person), (p3c:Person), (p3d:Person),
r3b = shortestPath((p3b)-[*..3]-(p3a)),
r3c = shortestPath((p3c)-[*..3]-(p3a)),
r3d = shortestPath((p3d)-[*..3]-(p3a))
WHERE p3a.name = "Dashwood, Francis, 11th Baron Le Despencer" and
p3b.name = "Stuart, John, 3rd Earl of Bute" and
p3c.name = "Wortley Montagu, Lady Mary" and
p3d.name = "Beauclerk, Harriot, 9th Duchess of St Albans"
//
// Bentinck, Margaret Cavendish, 2nd Duchess of Portland
// Monson, Lady Anne (1727-1776) 
// Graham, Catherine
// Wortley Montagu, Lady Mary
// Stuart, John, 3rd Earl of Bute
// TO
// Delany, Mary (1700-1788) Pair 3
//
OPTIONAL MATCH (p3fa:Person), (p3fb:Person), (p3fc:Person), (p3fd:Person), (p3fe:Person), (p3ff:Person),
r3fb = shortestPath((p3fb)-[*..3]-(p3fa)),
r3fc = shortestPath((p3fc)-[*..3]-(p3fa)),
r3fd = shortestPath((p3fd)-[*..3]-(p3fa)),
r3fe = shortestPath((p3fe)-[*..3]-(p3fa)),
r3ff = shortestPath((p3ff)-[*..3]-(p3fa))
WHERE p3fa.name = "Delany, Mary" and
p3fb.name = "Monson,s Lady Anne" and
p3fc.name = "Bentinck, Margaret Cavendish, 2nd Duchess of Portland" and
p3fd.name = "Graham, Catherine" and
p3fe.name = "Wortley Montagu, Lady Mary" and
p3ff.name = "Stuart, John, 3rd Earl of Bute"
//
// Villiers, Frances, 4th Countess of Jersey (1753-1821)
// Beauclerk, Lady Diana
// Cavendish, Georgiana, 5th Duchess of Devonshire
// TO
// Fitzroy, Augustus Henry, 3rd Duke of Grafton Pair 4
//
OPTIONAL MATCH (p4a:Person), (p4b:Person), (p4c:Person), (p4d:Person),
r4b = shortestPath((p4b)-[*..3]-(p4a)),
r4c = shortestPath((p4c)-[*..3]-(p4a)),
r4d = shortestPath((p4d)-[*..3]-(p4a))
WHERE p4a.name = "Fitzroy, Augustus Henry, 3rd Duke of Grafton" and
p4b.name = "Villiers, Frances, 4th Countess of Jersey" and
p4c.name = "Beauclerk, Lady Diana" and
p4d.name = "Cavendish, Georgiana, 5th Duchess of Devonshire" 
//
// Banks, Sarah Sophia
// Delany, Mary
// Solander, Daniel
// Beauclerk, Lady Diana
// Stuart, John, 3rd Earl of Bute
// Hamilton, Sir William
// Hamilton, Lady Emma
// Cavendish, Georgiana, 5th Duchess of Devonshire
// Monson, Lady Anne
// TO
// Banks, Sir Joseph Pair 5
//
OPTIONAL MATCH (p5a:Person), (p5b:Person), (p5c:Person), (p5d:Person), (p5e:Person), (p5f:Person), (p5g:Person), (p5h:Person), (p5i:Person), (p5j:Person),
r5b = shortestPath((p5b)-[*..3]-(p5a)),
r5c = shortestPath((p5c)-[*..3]-(p5a)),
r5d = shortestPath((p5d)-[*..3]-(p5a)),
r5e = shortestPath((p5e)-[*..3]-(p5a)),
r5f = shortestPath((p5f)-[*..3]-(p5a)),
r5g = shortestPath((p5g)-[*..3]-(p5a)),
r5h = shortestPath((p5h)-[*..3]-(p5a)),
r5i = shortestPath((p5i)-[*..3]-(p5a)),
r5j = shortestPath((p5j)-[*..3]-(p5a))
WHERE p5a.name = "Banks, Sir Joseph" and
p5b.name = "Banks, Sarah Sophia" and
p5c.name = "Delany, Mary" and
p5d.name = "Solander, Daniel" and
p5e.name = "Beauclerk, Lady Diana" and
p5f.name = "Stuart, John, 3rd Earl of Bute" and
p5g.name = "Hamilton, Sir William" and
p5h.name = "Hamilton, Lady Emma" and
p5i.name = "Cavendish, Georgiana, 5th Duchess of Devonshire" and
p5j.name = "Monson, Lady Anne" 
//
// Stuart, John, 3rd Earl of Bute (1713-1792)
// Solander, Daniel
// Cavendish-Bentinck, Dorothy, 3rd Duchess of Portland
// Rousseau, Jean-Jacques (1712-1778)
// TO 
// Bentinck, Margaret Cavendish, 2nd Duchess of Portland Pair 6 
//
OPTIONAL MATCH (p6fa:Person), (p6fb:Person), (p6fc:Person), (p6fd:Person), (p6fe:Person),
r6fb = shortestPath((p6fb)-[*..3]-(p6fa)),
r6fc = shortestPath((p6fc)-[*..3]-(p6fa)),
r6fd = shortestPath((p6fd)-[*..3]-(p6fa)),
r6fe = shortestPath((p6fe)-[*..3]-(p6fa))
WHERE p6fa.name = "Bentinck, Margaret Cavendish, 2nd Duchess of Portland" and
p6fb.name = "Solander, Daniel" and 
p6fc.name = "Stuart, John, 3rd Earl of Bute" and 
p6fd.name = "Cavendish-Bentinck, Dorothy, 3rd Duchess of Portland" and
p6fe.name = "Rousseau, Jean-Jacques"  
//
// Brydges, Cassandra, 1st Duchess of Chandos (1670-1735)  
// TO
// Mary Wortley Montagu (1689-1762) Pair 7
//
OPTIONAL MATCH (p7fa:Person), (p7fb:Person), (p7fc:Person),
r7fb = shortestPath((p7fb)-[*..3]-(p7fa)),
r7fc = shortestPath((p7fc)-[*..3]-(p7fa))
WHERE p7fa.name = "Wortley Montagu, Lady Mary" and
p7fb.name = "Brydges, Cassandra, 1st Duchess of Chandos" and
p7fc.name = "Stuart, John, 3rd Earl of Bute" 
//
// Hamilton, Lady Emma
// Cavendish, Georgiana, 5th Duchess of Devonshire
// Beckford, William Thomas
// Banks, Sarah Sophia
// TO
// Hamilton, Sir William Pair 8
//
OPTIONAL MATCH (p8a:Person), (p8b:Person), (p8c:Person), (p8d:Person), (p8e:Person),
r8b = shortestPath((p8b)-[*..3]-(p8a)),
r8c = shortestPath((p8c)-[*..3]-(p8a)),
r8d = shortestPath((p8d)-[*..3]-(p8a)),
r8e = shortestPath((p8e)-[*..3]-(p8a))
WHERE p8a.name = "Hamilton, Sir William" and
p8b.name = "Hamilton, Lady Emma" and
p8c.name = "Beckford, William Thomas" and
p8d.name = "Cavendish, Georgiana, 5th Duchess of Devonshire" and
p8e.name = "Banks, Sarah Sophia"
//
// Damer, Anne Seymour
// TO
// Cavendish, Georgiana, 5th Duchess of Devonshire Pair 9
//
OPTIONAL MATCH (p9fa:Person), (p9fb:Person),
r9fb = shortestPath((p9fb)-[*..3]-(p9fa))
WHERE p9fa.name = "Cavendish, Georgiana, 5th Duchess of Devonshire" and
p9fb.name = "Damer, Anne Seymour"
//
// Brydges, Cassandra, 1st Duchess of Chandos (1670-1735) 
// Petiver, James (1685-1718) 
// Hughes, Rev. Griffith (1707-1758)
// TO
// Compton, Henry, Bishop of London (1632-1713) Pair 11
//
OPTIONAL MATCH (p11a:Person), (p11b:Person), (p11c:Person), (p11d:Person),
r11b = shortestPath((p11b)-[*..3]-(p11a)),
r11c = shortestPath((p11c)-[*..3]-(p11a)),
r11d = shortestPath((p11d)-[*..3]-(p11a))
WHERE p11a.Pair <> p11b.Pair and 
p11a.name = "Compton, Henry, Bishop of London" and
p11b.name = "Brydges, Cassandra, 1st Duchess of Chandos" and
p11c.name = "Petiver, James" and
p11d.name = "Hughes, Rev. Griffith"
//
// Nihell, Elizabeth (1723-1776)
// TO
// Smellie, William (1697-1763) Pair 16
//
OPTIONAL MATCH (p16a:Person), (p16b:Person),
r16b = shortestPath((p16b)-[*..3]-(p16a))
WHERE p16a.name = "Smellie, William" and
p16b.name = "Nihell, Elizabeth"
//
// Graham, Catherine (1731-1791) 
// Monson, Lady Anne (1727-1776) 
// Withering, William
// Cavendish, Georgiana, 5th Duchess of Devonshire
// Hamilton, Lady Emma
// TO
// Graham, James (1745-1794) Pair 19
//
OPTIONAL MATCH (p19a:Person), (p19b:Person), (p19c:Person), (p19d:Person), (p19e:Person), (p19f:Person),
r19b = shortestPath((p19b)-[*..3]-(p19a)),
r19c = shortestPath((p19c)-[*..3]-(p19a)),
r19d = shortestPath((p19d)-[*..3]-(p19a)),
r19e = shortestPath((p19e)-[*..3]-(p19a)),
r19f = shortestPath((p19f)-[*..3]-(p19a))
WHERE p19a.name = "Graham, James" and
p19b.name = "Monson, Lady Anne" and
p19c.name = "Graham, Catherine" and
p19d.name = "Withering, William" and
p19e.name = "Cavendish, Georgiana, 5th Duchess of Devonshire" and
p19f.name = "Hamilton, Lady Emma" 
//
// Mead, Richard (1673-1754) 
// Petiver, James (1685-1718)
// Dillenius, Johann (1684-1747)
// TO 
// Sherard, James (1666-1738) Pair 21
//
OPTIONAL MATCH (p21a:Person), (p21b:Person), (p21c:Person), (p21d:Person),
r21b = shortestPath((p21b)-[*..3]-(p21a)),
r21c = shortestPath((p21c)-[*..3]-(p21a)),
r21d = shortestPath((p21d)-[*..3]-(p21a))
WHERE p21a.Pair <> p21b.Pair and 
p21a.name = "Sherard, James" and
p21b.name = "Mead, Richard" and
p21c.name = "Petiver, James" and
p21d.name = "Dillenius, Johan"
//
// Smellie, William (1697-1763)
// Brydges, Cassandra  (1670-1735) 
// Mead, Richard (1673-1754)
// Sherard, James (1666-1738)
// TO
// Blackwell, Elizabeth (1707-1758) 
//
OPTIONAL MATCH (p21fa:Person), (p21fb:Person), (p21fc:Person), (p21fd:Person), (p21fe:Person),
r21fb = shortestPath((p21fb)-[*..3]-(p21fa)),
r21fc = shortestPath((p21fc)-[*..3]-(p21fa)),
r21fd = shortestPath((p21fd)-[*..3]-(p21fa)),
r21fe = shortestPath((p21fe)-[*..3]-(p21fa))
WHERE p21fa.Pair <> p21fb.Pair and 
p21fa.name = "Blackwell, Elizabeth" and
p21fb.name = "Smellie, William" and
p21fc.name = "Brydges, Cassandra, 1st Duchess of Chandos" and
p21fd.name = "Mead, Richard" and
p21fe.name = "Sherard, James"
//
// Withering, William
// Jacson, Maria Elizabetha (1755-1829)
// Delany Mary
// Smellie, William
// Beauclerk, Lady Diana (1734-1808)
// TO 
//Darwin Erasmus Pair 22 
//
OPTIONAL MATCH (p22a:Person), (p22b:Person), (p22c:Person), (p22d:Person), (p22e:Person), (p22f:Person), 
r22b = shortestPath((p22b)-[*..3]-(p22a)),
r22c = shortestPath((p22c)-[*..3]-(p22a)),
r22d = shortestPath((p22d)-[*..3]-(p22a)),
r22e = shortestPath((p22e)-[*..3]-(p22a)),
r22f = shortestPath((p22f)-[*..3]-(p22a))
WHERE p22a.name = "Darwin, Erasmus" and
p22b.name = "Withering, William" and
p22c.name = "Jacson, Maria Elizabetha" and
p22d.name = "Delany, Mary" and
p22e.name = "Smellie, William" and
p22f.name = "Beauclerk, Lady Diana" 
//
// Damer, Anne Seymour
// Worsley, Lady Seymour Dorothy
// TO
// Smith-Stanley, Lady Elizabeth, 12th Countess of Derby II (1759-1829) Pair 22
//
OPTIONAL MATCH (p22fa:Person), (p22fb:Person), (p22fc:Person),
r22fb = shortestPath((p22fb)-[*..3]-(p22fa)),
r22fc = shortestPath((p22fc)-[*..5]-(p22fa))
WHERE p22fa.name = "Smith-Stanley, Lady Elizabeth, 12th Countess of Derby II" and
p22fb.name = "Damer, Anne Seymour" and
p22fc.name = "Worsley, Lady Seymour Dorothy"
//
// Lee, Ann
// Hughes, Rev. Griffith (1707-1758)
// Bentinck, Margaret Cavendish, 2nd Duchess of Portland (1715-1785)
// Clifford, George (1685-1760)
// Blackwell, Elizabeth (1707-1758) 
// TO 
// Ehret, Georg (1666-1738) Pair 23 
//
OPTIONAL MATCH (p23a:Person), (p23b:Person), (p23c:Person), (p23d:Person), (p23e:Person), (p23f:Person), (p23g:Person),
r23b = shortestPath((p23b)-[*..3]-(p23a)),
r23c = shortestPath((p23c)-[*..3]-(p23a)),
r23d = shortestPath((p23d)-[*..3]-(p23a)),
r23e = shortestPath((p23e)-[*..3]-(p23a)),
r23f = shortestPath((p23f)-[*..3]-(p23a)),
r23g = shortestPath((p23g)-[*..3]-(p23a))
WHERE p23a.Pair <> p23b.Pair and p23a.name = "Ehret, Georg" and
p23b.name = "Hughes, Rev. Griffith" and
p23c.name = "Petiver, James" and
p23d.name = "Bentinck, Margaret Cavendish, 2nd Duchess of Portland" and
p23e.name = "Clifford, George" and
p23f.name = "Blackwell, Elizabeth" and
p23g.name = "Lee, Ann" 

return r1b, r1c, r1d, r1e, r1f, r1g, r1h, r1i, r1fb, r1fc, r1fd, r3b, r3c, r3d, r3fb, r3fc, r3fd, r3fe, r3ff, r4b, r4c, r4d, r5b,
r5c, r5d, r5e, r5f, r5g, r5h, r5i, r5j, r6fb, r6fc, r6fd, r6fe, r7fb, r7fc, r8b, r8c, r8d, r8e, r9fb,
r11b, r11c, r11d, r16b, r19b, r19c, r19d, r19e, r19f, r21b, r21c, r21d, r21fb, r21fc, r21fd, r21fe, r22b, r22c, r22d, r22e, r22f,
r22fb, r22fc, r23b, r23c, r23d, r23e, r23f, r23g

Will rewrite and open as a new issue