Skip to content

Commit

Permalink
undirected query_edge
Browse files Browse the repository at this point in the history
  • Loading branch information
ILSparkle committed Dec 11, 2024
1 parent a2bf27e commit 5dccf4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cardinal/graph/neo4j.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def query_edge(self, head_key: str, tail_key: str) -> Optional[T]:
with self.driver.session() as session:
result = session.run(
"""
MATCH (h:Node {key: $head_key})-[r:EDGE]->(t:Node {key: $tail_key})
MATCH (h:Node {key: $head_key})-[r:EDGE]-(t:Node {key: $tail_key})
RETURN r
""",
head_key=head_key,
Expand Down
4 changes: 2 additions & 2 deletions tests/graph/test_graph_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def test_graph_storage():
]
storage.insert_edge(relation_keys_head, relation_keys_tail, relations)

# 查询边
relation = storage.query_edge("entity1", "entity2")
# 无向查询边
relation = storage.query_edge("entity2", "entity1")
assert relation is not None, "Relation from entity1 to entity2 should exist"
assert relation["desc"] == "Connected" and relation["strength"] == 1

Expand Down

0 comments on commit 5dccf4d

Please sign in to comment.