MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / test_bi_directional_path

Method test_bi_directional_path

tests/flow/test_path.py:80–116  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

78 self._assert_resultset_and_expected_mutually_included(redis_graph.query(query), query_info)
79
80 def test_bi_directional_path(self):
81 node0 = Node(node_id=0, label="L1")
82 node1 = Node(node_id=1, label="L1")
83 node2 = Node(node_id=2, label="L1")
84 edge01 = Edge(node0, "R1", node1, edge_id=0, properties={'value': 1})
85 edge12 = Edge(node1, "R1", node2, edge_id=1, properties={'value': 2})
86
87 redis_graph.add_node(node0)
88 redis_graph.add_node(node1)
89 redis_graph.add_node(node2)
90 redis_graph.add_edge(edge01)
91 redis_graph.add_edge(edge12)
92
93 redis_graph.flush()
94
95 # Rewrite the edges with IDs instead of node values to match how they are returned.
96 edge01 = Edge(0, "R1", 1, edge_id=0, properties={'value': 1})
97 edge12 = Edge(1, "R1", 2, edge_id=1, properties={'value': 2})
98 # Reverse direction edges which are not part of the graph. Read only values.
99 edge10 = Edge(1, "R1", 0, edge_id=0, properties={'value': 1})
100 edge21 = Edge(2, "R1", 1, edge_id=1, properties={'value': 2})
101
102 path010 = Path.new_empty_path().add_node(node0).add_edge(edge01).add_node(node1).add_edge(edge10).add_node(node0)
103 path0121 = Path.new_empty_path().add_node(node0).add_edge(edge01).add_node(node1).add_edge(edge12) \
104 .add_node(node2).add_edge(edge21).add_node(node1)
105 path01210 = Path.new_empty_path().add_node(node0).add_edge(edge01).add_node(node1).add_edge(edge12) \
106 .add_node(node2).add_edge(edge21).add_node(node1).add_edge(edge10).add_node(node0)
107 path121 = Path.new_empty_path().add_node(node1).add_edge(edge12).add_node(node2).add_edge(edge21).add_node(node1)
108 path1210 = Path.new_empty_path().add_node(node1).add_edge(edge12).add_node(node2).add_edge(edge21) \
109 .add_node(node1).add_edge(edge10).add_node(node0)
110 expected_results = [[path010], [path0121], [path01210], [path121], [path1210]]
111
112 query = "MATCH p=(:L1)-[:R1*]->(:L1)<-[:R1*]-() RETURN p"
113
114 query_info = QueryInfo(query=query, description="Tests bi directional variable length paths",
115 expected_result=expected_results)
116 self._assert_resultset_and_expected_mutually_included(redis_graph.query(query), query_info)
117
118 def test_bi_directional_path_functions(self):
119 node0 = Node(node_id=0, label="L1")

Callers

nothing calls this directly

Calls 5

QueryInfoClass · 0.90
NodeClass · 0.50
EdgeClass · 0.50
queryMethod · 0.45

Tested by

no test coverage detected