Skip to content

Commit

Permalink
Merge pull request #1797 from kuzudb/networkx-recursive-rel
Browse files Browse the repository at this point in the history
Add recursive rel support for networkx
  • Loading branch information
mewim committed Jul 10, 2023
2 parents 81fef9b + 56e125a commit 955c4c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tools/python_api/src_py/query_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ def encode_node_id(node, table_primary_key_dict):
rels[(_src["table"], _src["offset"], _dst["table"],
_dst["offset"])] = row[i]

elif column_type == Type.RECURSIVE_REL.value:
for node in row[i]['_nodes']:
_id = node["_id"]
nodes[(_id["table"], _id["offset"])] = node
table_to_label_dict[_id["table"]] = node["_label"]
for rel in row[i]['_rels']:
for key in rel:
if rel[key] is None:
del rel[key]
_src = rel["_src"]
_dst = rel["_dst"]
rels[(_src["table"], _src["offset"], _dst["table"],
_dst["offset"])] = rel

# Add nodes
for node in nodes.values():
_id = node["_id"]
Expand Down Expand Up @@ -313,7 +327,7 @@ def _get_properties_to_extract(self):
for i in range(len(column_names)):
column_name = column_names[i]
column_type = column_types[i]
if column_type in [Type.NODE.value, Type.REL.value]:
if column_type in [Type.NODE.value, Type.REL.value, Type.RECURSIVE_REL.value]:
properties_to_extract[i] = (column_type, column_name)
return properties_to_extract

Expand Down
1 change: 1 addition & 0 deletions tools/python_api/src_py/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ class Type(Enum):
REL = "REL"
NODE_ID = "NODE_ID"
STRUCT = "STRUCT"
RECURSIVE_REL = "RECURSIVE_REL"

0 comments on commit 955c4c5

Please sign in to comment.