test.py 480 B

12345678910111213141516
  1. from db.neo4j import get_neo4j_db
  2. graph = get_neo4j_db()
  3. node_id = 120
  4. result = graph.run(f"match path=(n:Basic)-[*]->(p:Basic) where id(n)={node_id} return nodes(path) as nodes,relationships(path) as relations")
  5. for r in result:
  6. nodes = r["nodes"]
  7. relations = r["relations"]
  8. for n in nodes:
  9. print(n.identity, n["name"])
  10. print("*" * 20)
  11. for r in relations:
  12. print(r.identity, type(r).__name__, r.start_node.identity, r.end_node.identity)