Skip to content

Commit 02710d6

Browse files
committed
changed readme
1 parent 7db8259 commit 02710d6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ result = redis_graph.query(query)
5656
for record in result.result_set:
5757
path = record[0]
5858
# See path.py for more path API.
59-
print(path.edge_count(), path.nodes_count())
59+
print(path)
6060

6161

6262
# All done, remove graph.

redisgraph/path.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,17 @@ def add_edge(self, edge):
5151

5252
def __eq__(self, other):
5353
return self.nodes == other.nodes and self.edges == other.edges
54+
55+
def __str__(self):
56+
res = "<"
57+
edge_count = self.edge_count()
58+
for i in range(0, edge_count):
59+
node_id = self.get_node(i).id
60+
res += "(" + str(node_id) + ")"
61+
edge = self.get_relationship(i)
62+
res += "-[" + str(int(edge.id)) + "]->" if edge.src_node == node_id else "<-[" + str(int(edge.id)) + "]-"
63+
node_id = self.get_node(edge_count).id
64+
res += "(" + str(node_id) + ")"
65+
res += ">"
66+
return res
67+

0 commit comments

Comments
 (0)