You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
1.6 KiB

  1. CREATE (a:Fighter{name:'Khabib Nurmagomedov', weight:'155'}),
  2. (b:Fighter{name:'Rafael Dos Anjos', weight:'155'}),
  3. (c:Fighter{name:'Neil Magny', weight:'170'}),
  4. (d:Fighter{name:'Jon Jones', weight:'205'}),
  5. (e:Fighter{name:'Daniel Cormier', weight:'205'}),
  6. (f:Fighter{name:'Michael Bisping', weight:'185'}),
  7. (g:Fighter{name:'Matt Hamill', weight:'185'}),
  8. (h:Fighter{name:'Brandon Vera', weight:'205'}),
  9. (i:Fighter{name:'Frank Mir', weight:'230'}),
  10. (j:Fighter{name:'Brock Lesnar', weight:'230'}),
  11. (k:Fighter{name:'Kelvin Gastelum', weight:'185'}),
  12. (a)-[:beats]->(b),
  13. (b)-[:beats]->(c),
  14. (d)-[:beats]->(e),
  15. (f)-[:beats]->(g),
  16. (d)-[:beats]->(h),
  17. (h)-[:beats]->(i),
  18. (i)-[:beats]->(j),
  19. (c)-[:beats]->(k),
  20. (k)-[:beats]->(f),
  21. (k)-[:beats]->(f),
  22. (f)-[:beats]->(g),
  23. (f)-[:beats]->(k),
  24. (g)-[:beats]->(d)
  25. # visualize
  26. MATCH (a: Fighter)-[r]-(b) RETURN r, a, b;
  27. # middle/welter/light
  28. MATCH (a: Fighter)-[:beats]->()
  29. WHERE a.weight = '155' OR a.weight = '170' OR a.weight = '185'
  30. RETURN a.weight, collect(DISTINCT a.name)
  31. # 1-1
  32. MATCH (a: Fighter)-[r1:beats]->(b: Fighter)-[r2:beats]->(c: Fighter)
  33. WITH a, b, c, count(*) AS cnt
  34. WHERE a = c AND cnt = 1
  35. RETURN a, b;
  36. # gretest number of fights
  37. MATCH (a: Fighter)-[r:beats]->()
  38. WITH a.name as name, count(a.name) as cnt
  39. CALL {
  40. MATCH (a: Fighter)-[r:beats]->()
  41. WITH a.name as name, count(a.name) as cnt
  42. RETURN max(cnt) as mx
  43. }
  44. WITH name, cnt, mx
  45. WHERE cnt = mx
  46. RETURN name
  47. # Undefeated
  48. MATCH (a: Fighter)
  49. WHERE NOT EXISTS (()-[:beats]->(a))
  50. RETURN a
  51. # defeated
  52. MATCH (a: Fighter)
  53. WHERE NOT EXISTS ((a)-[:beats]->())
  54. RETURN a