11create.mql 844 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. -- ============================================================
  2. -- Cypher 创建图和关系测试
  3. -- ============================================================
  4. -- 1. match 节点
  5. match (:test_graph) return *
  6. /**
  7. output()
  8. **/
  9. ;
  10. -- 2. match 特定类型节点
  11. match (a:test_graph) where a.g_type='type_a' return a
  12. /**
  13. output()
  14. **/
  15. ;
  16. -- 3. 创建关系(connect edge)
  17. match (a:test_graph), (b:test_graph) where a.g_name='node_a' and b.g_name='node_b'
  18. create (a) -[:connect]-> (b)
  19. ;
  20. -- 4. 创建更多关系
  21. match (a:test_graph), (b:test_graph) where a.g_name='node_c' and b.g_name='node_d'
  22. create (a) -[:connect]-> (b)
  23. ;
  24. match (a:test_graph), (b:test_graph) where a.g_name='node_a' and b.g_name='node_c'
  25. create (a) -[:connect]-> (b)
  26. ;
  27. -- 5. 查询关系
  28. match (a:test_graph) -[:connect]-> (b:test_graph) return a, b
  29. /**
  30. output()
  31. **/
  32. ;